fix(source-facebook-marketing): catch FacebookBadObjectError in non-insight stream read_records (AI-Triage PR)#75199
Draft
devin-ai-integration[bot] wants to merge 3 commits intomasterfrom
Conversation
…nsight stream read_records Add exception handling for FacebookBadObjectError in FBMarketingStream.read_records() and FBMarketingReversedIncrementalStream.read_records(). This error was already handled in async_job.py (with retry) and base_insight_streams.py (with AirbyteTracedException), but non-insight streams like Ads, AdSets, Campaigns, etc. had no handling for it. The error occurs when the Facebook Business SDK receives malformed/inconsistent data from the API during pagination. It is classified as transient_error since this is a known intermittent issue with the Meta API. Related to airbytehq/oncall#11697 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:
|
Contributor
👋 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
|
Co-Authored-By: bot_apk <apk@cognition.ai>
Contributor
|
Co-Authored-By: bot_apk <apk@cognition.ai>
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/11697:
Adds exception handling for
FacebookBadObjectErrorin tworead_records()methods inbase_streams.py— specificallyFBMarketingStreamandFBMarketingReversedIncrementalStream. Previously, when the Facebook SDK received malformed data during pagination (HTTP 200 but unparseable response body), the raw SDK exception propagated unhandled, producing an opaquesystem_error. This change catches it and re-raises as anAirbyteTracedExceptionwithFailureType.transient_error, consistent with howasync_job.pytreats the same exception (retry-worthy) and giving the platform a chance to retry.Prior art in this connector:
async_job.py— retriesFacebookBadObjectErrorup to 10 times with exponential backoffbase_insight_streams.py— catches it and raisesAirbyteTracedException(but withsystem_error)This PR aligns the non-insight streams with the existing pattern, choosing
transient_erroroversystem_errorsince the Sentry data shows this is intermittent and retry-resolvable.Review & Testing Checklist for Human
transient_erroris the correct FailureType.base_insight_streams.pyusessystem_errorfor the same exception. This PR usestransient_errorbased on Sentry evidence that the error is intermittent. Confirm this is the desired platform retry behavior and won't mask persistent failures.patches.py(the cursor-level code where the exception originates). Determine if both fixes are needed or if one supersedes the other.async_job.pywhich retries with backoff, this PR relies on the platform's transient-error retry. Validate that platform-level retry is sufficient here.Suggested test plan: Trigger a sync on a Facebook Marketing source with a high volume of paginated data (e.g., Ads or AdSets stream with many records). Verify that if a
FacebookBadObjectErroroccurs, the sync is retried automatically by the platform rather than failing withsystem_error. If possible, compare behavior with and without this patch on the same account/stream.Notes
patches.py:load_next_page()→build_objects_from_response()when the Facebook API returns a 200 with malformed/inconsistent payload during pagination.ruff(CI Format Check).Link to Devin session: https://app.devin.ai/sessions/e749f1f0071d4f1f8cd33515ba7c8b09