fix: wrap _check_dynamic_streams_availability in try/except#990
Draft
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Draft
fix: wrap _check_dynamic_streams_availability in try/except#990devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Conversation
Match the sibling _check_stream_availability pattern by funneling resolution errors through self._log_error so that failures raised while accessing source.resolved_manifest or source.dynamic_streams surface as (False, message) instead of a raw Python traceback. 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/1776378187-fix-dynamic-streams-check-exception#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/1776378187-fix-dynamic-streams-check-exceptionPR 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.
Resolves https://github.com/airbytehq/airbyte-internal-issues/issues/16199:
Summary
CheckStream._check_dynamic_streams_availabilityinairbyte_cdk/sources/declarative/checks/check_stream.pypreviously accessedsource.resolved_manifestandsource.dynamic_streamswithout any error handling. When those accesses raised — e.g., when aConfigComponentsResolverfails during manifest resolution — the exception propagated all the way up throughcheck_connectionand surfaced to users as a raw Python traceback instead of a clean(False, message)→AirbyteConnectionStatus.FAILED.This PR wraps the dynamic-stream resolution lines in
try/except, funneling errors throughself._log_error(...), matching the existing pattern already used in the sibling_check_stream_availabilitymethod in the same file.Changes
airbyte_cdk/sources/declarative/checks/check_stream.py: wrap thesource.resolved_manifest.get(...)/source.dynamic_streams/_map_generated_streams(...)block intry/except Exception as errorand returnself._log_error(logger, "resolving dynamic streams for check", error)on failure. The# type: ignore[...]comments are preserved and the post-try/exceptloop is unchanged.unit_tests/sources/declarative/checks/test_check_stream.py: add a parametrized unit test that constructs aCheckStreamwith a non-emptydynamic_streams_check_configslist, injects a fakeSourcethat raises during dynamic stream resolution (once viaresolved_manifest.get(...)and once via thedynamic_streamsproperty), and asserts thatcheck_connectionreturns(False, <error message>)instead of raising.Context
The triggering discovery is airbytehq/airbyte#76373 (source-google-ads), which activates this previously-inert code path by adding
dynamic_streams_check_configsto the Google Ads manifest.Declarative-First Evaluation
Not applicable — this is a defensive error-handling fix inside the Python CDK itself (not a connector manifest change).
Breaking Change Evaluation
Not a breaking change. No schema, spec, PK, cursor, stream set, or state format changes. Purely defensive error handling — happy-path behavior is unchanged, and the only observable difference is that previously-unhandled exceptions now return a clean
(False, message)pair instead of a raw traceback.Review & Testing Checklist for Human
Exceptioninside_check_dynamic_streams_availabilityis acceptable for consistency with_check_stream_availability, even though the repo's general Python standards discourage broadexcept Exceptionblocks).Suggested end-to-end verification: run a manifest-based source whose
resolved_manifestordynamic_streamsresolution fails (e.g., a manifest with a misconfiguredConfigComponentsResolver) and confirmcheckreturns aFAILEDstatus with theresolving dynamic streams for checkerror message rather than an unhandled traceback.Notes
Keeping this as a draft per repo convention. The fix scope matches the triage report exactly (lines 122-149). There is a related but separate concern at
check_stream.py:94-95wherehasattr(source, "dynamic_streams")can itself propagate a non-AttributeErrorraised from thedynamic_streamsproperty — the new test's second parametrization covers that via a two-call counter (first access succeeds throughhasattr, second raises inside the method body).Link to Devin session: https://app.devin.ai/sessions/95e2723a3e234d2d9d161792bc94d75b