Repository navigation
fix(source-amazon-seller-partner): Use streaming JSON decoder for Brand Analytics reports - #79647
devin-ai-integration[bot] wants to merge 3 commits into
Conversation
…nd Analytics reports Replace the buffered GzipJsonDecoder with a new StreamingGzipJsonDecoder for the 5 Brand Analytics streams that can produce multi-GB JSON reports. The new decoder: - Decompresses gzip incrementally - Parses JSON character-by-character to locate the target array - Yields individual records without materializing the full document This reduces peak memory from ~15GB (4-5x the uncompressed 3.2GB payload) to approximately the compressed size (~300MB) plus one record at a time, preventing OOM kills (exit code 137) on large Brand Analytics reports. Co-Authored-By: bot_apk <apk@cognition.ai>
🤖 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
|
Co-Authored-By: bot_apk <apk@cognition.ai>
|
Deploy preview for airbyte-docs ready!
Deployed with vercel-action |
Co-Authored-By: bot_apk <apk@cognition.ai>
|
↪️ Triggering Reason: Draft PR with CI passing (unrelated Connector CI Summary check), fixes OOM on Brand Analytics reports.\n\n- https://github.com/airbytehq/oncall/issues/12143 |
|
🧪 Fix Validation Evidence🟢 Outcome: Fix Proven — No Regression DetectedThe 📋 Evidence PlanTesting Strategy: Regression Tests Only (source connector, no forced OAuth, standard logic change) Proving Criteria: No regression in SPEC/CHECK/DISCOVER/READ when comparing target (5.7.8-dev) vs control (5.7.7) Hypothesis: ✅-no-difference expected. The ✅ Pre-flight Checks (all passed)
🔬 Regression Test ResultsAttempt 1: All Streams (GSM credentials)
Attempt 2: Selected Brand Analytics Streams Only (GSM credentials)
READ Analysis: Both versions produce identical failure (exit_code=1, 70 LOG, 25 TRACE, 4 STATE messages each, 0 records). This confirms the GSM test account lacks Brand Analytics report access. The fix is an edge-case-only optimization — it only activates on multi-GB payloads that no test account produces. Comparison: 📊 Evidence AssessmentWhy this is sufficient evidence:
Pre-release published: Recommendation: Fix is proven safe. Recommend |
|
|
What
Resolves https://github.com/airbytehq/oncall/issues/12143:
Customers syncing
GET_BRAND_ANALYTICS_SEARCH_TERMS_REPORT(and other Brand Analytics streams) experience OOM kills (exit code 137) when report payloads exceed ~1GB uncompressed. The existingGzipJsonDecodermaterializes the entire decompressed document + parsed object tree in memory, requiring 4-5x the uncompressed payload size (~15GB for a 3.2GB report). Even 8GB containers are insufficient.How
Added
StreamingGzipJsonDecodercustom component incomponents.pythat:gzip.GzipFile.read(chunk_size)json.loadson each complete objectPeak memory: compressed payload + one decompressed chunk + one record ≈ ~300MB vs the previous ~15GB.
Updated
manifest.yamlto useStreamingGzipJsonDecoderwithitems_fieldfor the 5 Brand Analytics streams and set theirdownload_extractor.field_pathto[](decoder now yields individual items directly).No new dependencies — uses only Python stdlib (
gzip,json).Declarative-First Evaluation
Evaluated declarative CDK alternatives. A CDK-level
JsonItemsDecoderis in-flight (airbytehq/airbyte-python-cdk#1026) but not yet merged. This PR uses a custom component with stdlib only so the fix is not blocked on CDK release. Once the CDK component lands, this can be refactored to a manifest-only change with no custom code.Review guide
components.py— newStreamingGzipJsonDecoderclass (~130 lines) after existingGzipJsonDecodermanifest.yaml— 5 Brand Analytics streams switched fromGzipJsonDecodertoStreamingGzipJsonDecoderwith appropriateitems_fieldunit_tests/test_streaming_gzip_json_decoder.py— 12 parametrized tests covering gzip/non-gzip, edge cases, incremental yielding, escaped characters, nested structuresUser Impact
Can this PR be safely reverted and rolled back?
Link to Devin session: https://app.devin.ai/sessions/d8646a8c715e4db3baef3d7cbfc5988d