fix: handle EOFError in monkey_patched_get_item for corrupted cache entries#984
Draft
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Draft
fix: handle EOFError in monkey_patched_get_item for corrupted cache entries#984devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Conversation
…ntries When the SQLite cache contains corrupted/truncated pickle data (which can happen due to fast_save=True + synchronous=OFF), the requests_cache deserialization pipeline raises EOFError. This was not caught, causing the sync to crash. Catch EOFError during deserialization and convert it to KeyError, which requests_cache treats as a cache miss and transparently re-fetches from the upstream API. 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/1775605599-fix-eoferror-monkey-patch#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/1775605599-fix-eoferror-monkey-patchPR 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
Resolves https://github.com/airbytehq/oncall/issues/11909:
The
monkey_patched_get_itemfunction inhttp_client.pydoes not handleEOFErrorthat can occur whenself.deserialize()encounters corrupted/truncated pickle data in the SQLite cache. This corruption can happen due tofast_save=True+synchronous=OFF(as noted in existing code comments). The error propagates uncaught and crashes the sync.The fix wraps the
self.deserialize(key, row[0])call in atry/except EOFErrorthat raisesKeyError(key)instead, treating the corrupted entry as a cache miss. This causesrequests_cacheto transparently re-fetch from the upstream API. This is the same pattern used in python-diskcache for the same issue.Observed in production via Sentry on source-hubspot v6.4.2 (stream:
deal_splits), but this is a CDK-level fix benefiting all connectors using HTTP caching.Review & Testing Checklist for Human
EOFError? Other deserialization errors are possible (e.g.,pickle.UnpicklingError). The Sentry traces specifically showEOFError, but consider whether a broader catch (e.g.,Exceptionwith a log warning) would be more resilient. A narrower catch is safer but may not cover all corruption modes.KeyErroris the correct cache-miss signal. Confirm that raisingKeyErrorfrom__getitem__causesrequests_cacheto treat the entry as missing and re-fetch, rather than triggering unexpected behavior.Notes
test_assert_requests_cache_versiontest is unchanged and still guards against silentrequests_cacheupgrades.sqlite3.InterfaceError; this extends it forEOFError.Link to Devin session: https://app.devin.ai/sessions/01100afa4b594aa8a286f53cedc5984b