fix: use isinstance() fallback for exception subclass matching in HttpStatusErrorHandler#1006
Draft
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Draft
Conversation
…tusErrorHandler The interpret_response() method used exact class matching (dict.get) to look up exception types in the error mapping. This caused subclasses of RequestException (e.g. ConnectionError, ChunkedEncodingError, ReadTimeout) to fall through to the else branch, producing misleading 'Unexpected exception in error handler' messages classified as system_error instead of transient_error. Add an isinstance()-based fallback that iterates through exception type keys in the mapping when exact class lookup returns None. Exact match still takes precedence for performance and specificity. 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/1777536479-fix-isinstance-error-mapping#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/1777536479-fix-isinstance-error-mappingPR 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
HttpStatusErrorHandler.interpret_response()used exact class matching (dict.get(exception.__class__)) to look up exception types in the error mapping. TheDEFAULT_ERROR_MAPPINGmapsRequestExceptiontotransient_error, but when a subclass likeConnectionErrororChunkedEncodingErrorwas encountered,dict.get(ConnectionError)returnedNonebecause it is not the same class asRequestException.This caused transient network errors to fall through to the
elsebranch, producing the misleading message"Unexpected exception in error handler"and classifying them assystem_errorinstead oftransient_error.Fix: After the exact
dict.get()lookup fails, iterate through the mapping's exception-type keys and useisinstance()to find a match. Exact class match still takes precedence for performance and specificity.Resolves https://github.com/airbytehq/oncall/issues/12124:
Declarative-First Evaluation
Not applicable — this is a CDK-level fix in the imperative HTTP error handler infrastructure, not a connector-level change.
Test Coverage
Added 7 new test cases covering the fix:
ConnectionError,ChunkedEncodingError,ReadTimeout,ConnectTimeout) — all resolve totransient_errorvia theRequestExceptionmappingisinstancefallback works with user-provided mappingsisinstancefallbackRequestException(exact match),Exception(unmapped), and other paths continue to passBreaking Change Evaluation
Not a breaking change. The fix only adds a fallback lookup path — existing exact-match behavior is preserved. No public API, schema, spec, or state format changes.
Review & Testing Checklist for Human
isinstance()fallback iteration order is acceptable (it uses dict insertion order, matching the first parent class found)issubclass(mapped_key, Exception)guard is sufficient to skip non-exception keys (int status codes) during iterationNotes
semantic-pr-release-drafterfor versioning, so no manual version bump is needed.HttpStatusErrorHandler(or the default error handler) without requiring any connector-level changes.Link to Devin session: https://app.devin.ai/sessions/4550ef11ab60443096c77cfe3fc6854f