Skip to content

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
devin/1773873199-fix-facebook-bad-object-error
Draft

fix(source-facebook-marketing): catch FacebookBadObjectError in non-insight stream read_records (AI-Triage PR)#75199
devin-ai-integration[bot] wants to merge 3 commits intomasterfrom
devin/1773873199-fix-facebook-bad-object-error

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Mar 18, 2026

Summary

Resolves https://github.com/airbytehq/oncall/issues/11697:

Adds exception handling for FacebookBadObjectError in two read_records() methods in base_streams.py — specifically FBMarketingStream and FBMarketingReversedIncrementalStream. Previously, when the Facebook SDK received malformed data during pagination (HTTP 200 but unparseable response body), the raw SDK exception propagated unhandled, producing an opaque system_error. This change catches it and re-raises as an AirbyteTracedException with FailureType.transient_error, consistent with how async_job.py treats the same exception (retry-worthy) and giving the platform a chance to retry.

Prior art in this connector:

  • async_job.py — retries FacebookBadObjectError up to 10 times with exponential backoff
  • base_insight_streams.py — catches it and raises AirbyteTracedException (but with system_error)

This PR aligns the non-insight streams with the existing pattern, choosing transient_error over system_error since the Sentry data shows this is intermittent and retry-resolvable.

Review & Testing Checklist for Human

  • Verify transient_error is the correct FailureType. base_insight_streams.py uses system_error for the same exception. This PR uses transient_error based on Sentry evidence that the error is intermittent. Confirm this is the desired platform retry behavior and won't mask persistent failures.
  • Check relationship with airbytehq/airbyte#73709 which addresses a similar error in patches.py (the cursor-level code where the exception originates). Determine if both fixes are needed or if one supersedes the other.
  • Confirm no retry loop is needed at this level. Unlike async_job.py which 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 FacebookBadObjectError occurs, the sync is retried automatically by the platform rather than failing with system_error. If possible, compare behavior with and without this patch on the same account/stream.

Notes

  • This is an AI-Triage Draft PR. The fix is intentionally minimal — catch-and-classify only, no retry logic at the stream level.
  • The error originates in patches.py:load_next_page()build_objects_from_response() when the Facebook API returns a 200 with malformed/inconsistent payload during pagination.
  • Import ordering was corrected in a follow-up commit to satisfy ruff (CI Format Check).

Link to Devin session: https://app.devin.ai/sessions/e749f1f0071d4f1f8cd33515ba7c8b09

…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>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@github-actions
Copy link
Contributor

👋 Greetings, Airbyte Team Member!

Here are some helpful tips and reminders for your convenience.

💡 Show Tips and Tricks

PR Slash Commands

Airbyte Maintainers (that's you!) can execute the following slash commands on your PR:

  • 🛠️ Quick Fixes
    • /format-fix - Fixes most formatting issues.
    • /bump-version - Bumps connector versions, scraping changelog description from the PR title.
  • ❇️ AI Testing and Review (internal link: AI-SDLC Docs):
    • /ai-prove-fix - Runs prerelease readiness checks, including testing against customer connections.
    • /ai-canary-prerelease - Rolls out prerelease to 5-10 connections for canary testing.
    • /ai-review - AI-powered PR review for connector safety and quality gates.
  • 🚀 Connector Releases:
    • /publish-connectors-prerelease - Publishes pre-release connector builds (tagged as {version}-preview.{git-sha}) for all modified connectors in the PR.
    • /bump-progressive-rollout-version - Bumps connector version with an RC suffix (2.16.10-rc.1) for progressive rollouts (enableProgressiveRollout: true).
      • Example: /bump-progressive-rollout-version changelog="Add new feature for progressive rollout"
  • ☕️ JVM connectors:
    • /update-connector-cdk-version connector=<CONNECTOR_NAME> - Updates the specified connector to the latest CDK version.
      Example: /update-connector-cdk-version connector=destination-bigquery
  • 🐍 Python connectors:
    • /poe connector source-example lock - Run the Poe lock task on the source-example connector, committing the results back to the branch.
    • /poe source example lock - Alias for /poe connector source-example lock.
    • /poe source example use-cdk-branch my/branch - Pin the source-example CDK reference to the branch name specified.
    • /poe source example use-cdk-latest - Update the source-example CDK dependency to the latest available version.
  • ⚙️ Admin commands:
    • /force-merge reason="<REASON>" - Force merges the PR using admin privileges, bypassing CI checks. Requires a reason.
      Example: /force-merge reason="CI is flaky, tests pass locally"
📚 Show Repo Guidance

Helpful Resources

📝 Edit this welcome message.

Co-Authored-By: bot_apk <apk@cognition.ai>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 18, 2026

source-facebook-marketing Connector Test Results

354 tests   350 ✅  14s ⏱️
  2 suites    4 💤
  2 files      0 ❌

Results for commit 7086c92.

♻️ This comment has been updated with latest results.

Co-Authored-By: bot_apk <apk@cognition.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant