Repository navigation
fix: improve oneOf/anyOf config validation error messages - #972
Closed
devin-ai-integration[bot] wants to merge 1 commit into
Closed
devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
Replace validate() with Draft7Validator.iter_errors() to detect oneOf/anyOf validation failures and produce per-branch error details instead of surfacing a misleading error from the last non-matching branch (e.g. "'Service' was expected" when the user intended OAuth). The improved message lists each oneOf option by title with the specific validation errors for that branch, making it actionable for users to identify which required fields are missing in their chosen auth method. Co-Authored-By: bot_apk <apk@cognition.ai>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
👋 Greetings, Airbyte Team Member!Here are some helpful tips and reminders for your convenience. 💡 Show Tips and TricksTesting This CDK VersionYou can test this version of the CDK using the following: # Run the CLI from this branch:
uvx 'git+https://github.com/airbytehq/airbyte-python-cdk.git@devin/1775052273-improve-oneof-validation-error#egg=airbyte-python-cdk[dev]' --help
# Update a connector to use the CDK from this branch ref:
cd airbyte-integrations/connectors/source-example
poe use-cdk-branch devin/1775052273-improve-oneof-validation-errorPR Slash CommandsAirbyte Maintainers can execute the following slash commands on your PR:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Improves the user-facing error message produced when config validation fails on a
oneOforanyOfschema (e.g., authentication method selection). Previously,jsonschema.validate()usedbest_matchinternally, which often surfaced a misleading error from the last non-matching branch — for example,"Config validation error: 'Service' was expected"when the user intended OAuth but was missingclient_secret. This affects all connectors usingoneOfwithconstdiscriminators (source-google-sheets,source-google-analytics-data-api,source-mailchimp, etc.).The fix switches from
validate()toDraft7Validator.iter_errors(), which exposes the full error tree. When aoneOf/anyOferror is detected, the new_format_oneof_errorhelper formats a message listing each branch by itstitle(or "option N") with the specific validation failures for that branch.Before:
Config validation error: 'Service' was expectedAfter:
Config validation error: the provided configuration for "credentials" does not match any supported option. OAuth Credentials: 'client_secret' is a required property | Service Account Key: 'Service' was expected; 'service_account_info' is a required property.For non-oneOf validation errors, behavior is preserved: the first error's message is used directly.
Resolves https://github.com/airbytehq/airbyte-internal-issues/issues/16138
Related to https://github.com/airbytehq/oncall/issues/11841
Review & Testing Checklist for Human
best_match(viavalidate()) to pick the most relevant error; the new code useserrors[0]fromiter_errors(). Verify that common non-oneOf validation failures (e.g., missing required top-level field, wrong type) still produce clear messages. These may differ subtly from the old behavior.internal_message: The newinternal_messageincludessub.messageandlist(sub.absolute_path). Confirm thatabsolute_pathonly contains field names (keys), never config values, so secrets are not exposed._format_oneof_error: Consider schemas with nested oneOf, anyOf (not oneOf), branches withouttitle, or emptycontext. The function handles missing titles (falls back to "option N") but doesn't have explicit test coverage._format_oneof_erroror the oneOf-specific path incheck_config_against_spec_or_exit. Consider adding tests for: (a) oneOf with titled branches, (b) oneOf without titles, (c) anyOf, (d) non-oneOf errors preserved.Suggested manual test: Run a connector that uses
oneOfauth (e.g.,source-google-sheets) with an intentionally incomplete OAuth config and verify the improved error message surfaces in the check output.Notes
FailureTyperemainsconfig_error— no change in retry/classification behavior, so this is not a breaking change.semantic-pr-release-drafterbased on thefix:PR title prefix.Link to Devin session: https://app.devin.ai/sessions/ef29e8d43f4e405d969a118acacb723d