fix(source-facebook-marketing): Handle FacebookBadObjectError in base stream read_records#74890
Conversation
… stream read_records Catch FacebookBadObjectError in FBMarketingStream.read_records() and FBMarketingReversedIncrementalStream.read_records() to prevent transient crashes when the Facebook API returns inconsistent/corrupted object data. The error is raised as a transient AirbyteTracedException so the platform retries the sync attempt automatically. Previously this error was only handled in the insight streams (async jobs), leaving non-insight streams like Activities vulnerable to unhandled crashes. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 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 TricksPR Slash CommandsAirbyte Maintainers (that's you!) can execute the following slash commands on your PR:
📚 Show Repo GuidanceHelpful Resources
|
|
|
Deploy preview for airbyte-docs ready! ✅ Preview Built with commit b3f919f. |
...tions/connectors/source-facebook-marketing/source_facebook_marketing/streams/base_streams.py
Fixed
Show fixed
Hide fixed
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
↪️ Triggering Reason: Draft PR with CI passing (354 tests, 350 pass, 4 skipped, 0 failures). Fix addresses FacebookBadObjectError crash in non-insight streams. |
|
Fix Validation Evidence —
|
|
What
Non-insight streams (e.g.
activities,videos,images) crash with an unhandledFacebookBadObjectError("Bad data to set object data")when the Facebook API returns inconsistent/corrupted data during pagination. This causes entire sync attempts to fail. Observed in production where theactivitiesstream failed 3 consecutive attempts before eventually succeeding on retry.The insight streams already handle this error (in
base_insight_streams.py), but the base stream classes did not.How
Catch
FacebookBadObjectErrorin bothread_recordsmethods inbase_streams.py:FBMarketingStream.read_records()— used byActivities,Ads,AdSets,Campaigns, etc.FBMarketingReversedIncrementalStream.read_records()— used byVideos,ImagesThe error is re-raised as an
AirbyteTracedExceptionwithFailureType.transient_errorso the platform automatically retries the sync attempt.Review guide
The diff is minimal — only new imports and two new
exceptblocks:base_streams.py): AddedFacebookBadObjectError,FailureType,AirbyteTracedException.FBMarketingStream.read_records()(~line 199): Newexcept FacebookBadObjectErrorblock — primary fix.FBMarketingReversedIncrementalStream.read_records()(~line 417): Same handler added to the secondread_recordsmethod.Human review checklist
transient_errorbecause the error resolves on retry.base_insight_streams.pyusessystem_errorfor the same exception — confirm whethertransient_erroris preferred here or if consistency matters more.exceptblocks are not covered by unit tests. The Facebook SDK raisesFacebookBadObjectErrorduring response parsing, which is difficult to mock without integration-level tests. Existing tests pass (354 tests, 350 ✅, 4 skipped).User Impact
Streams like
activitieswill no longer cause unhandled crashes when Facebook returns corrupted data. Instead, the platform will see a transient error and automatically retry, improving sync reliability.Can this PR be safely reverted and rolled back?
Link to Devin session: https://app.devin.ai/sessions/f25af3320c304c15a43d641f414d5044
Requested by: Rajath sinha (@rajathsinhaa)