Repository navigation
fix(sources): parse JSON from non-seekable zip-entry streams - #1768
Conversation
iter_json_stream_with rewinds via handle.seek(0) for its ijson multi-strategy parse, but a zip entry (zipfile.ZipExtFile, reached via process_zip -> _emit_individual) is not seekable, so every JSON export inside a .zip failed with 'File or stream is not seekable' and was skipped at ingest. Materialize a non-seekable handle into a BytesIO once before the seeking strategies. Fixes test_source_laws (zip round-trip + raw-capture) and test_acquisition_encoding (zip BOM/partial-corruption).
|
Warning Review limit reached
More reviews will be available in 16 minutes and 47 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bf331a10fb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # into a seekable buffer once before the seeking strategies run. | ||
| seekable = getattr(handle, "seekable", None) | ||
| if callable(seekable) and not seekable(): | ||
| handle = io.BytesIO(handle.read()) |
There was a problem hiding this comment.
Avoid buffering full non-seekable JSON entries in memory
For ZIP ingestion, open_bounded_zip_entry() provides a non-seekable stream and the configured decompression ceiling is 10 GiB, so a large but valid .json entry now gets fully decompressed into a BytesIO here before any records are yielded. This removes the existing streaming behavior for root-array exports where the first ijson.items(..., "item") strategy can succeed without rewinding, and can OOM on multi-GB archives that are still below the allowed entry size; consider spooling to a bounded temp file or only materializing when a fallback actually needs a rewind.
Useful? React with 👍 / 👎.
## Summary Three more inherited-failure fixes (continuing #1765/#1767/#1768). ## Changes - **`blackboard list --limit`**: used `-n`, violating the repo-wide `-l/--limit` convention enforced by `test_flag_aliases_consistent`. Aligned to `-l` (small CLI fix). - **`exercise_catalog`**: dropped the `insights analytics` nested path from the pin — that command path no longer exists. - **`config source_roots`**: the TOML serializer now renders arrays multi-line (`roots = [\n "/a",\n "/b",\n]`); the test pinned the old single-line spelling. Assert the array shape + members robustly. (Confirmed the cli-override is correctly applied — it was purely a formatting-style drift.) ## Verification ``` pytest <theme_aliases, exercise_catalog, config source_roots, help/terminal snapshots> # all pass ``` ## Deferred (intentionally not touched) The remaining inherited failures cluster on the **in-flux `provider`/`source_name` vocabulary** (#1743 is actively redesigning this) and a product decision — editing them blind risks encoding the wrong interpretation: - `resilience` (4), `ingestion_chaos`, `parsing_service`, `pipeline_probe` (2), `parsers_local_agent` — all turn on parsed `source_name` being the source-config name (`'test'`) vs the detected origin (`'claude-code'`/`'codex'`). Likely a real regression in the origin-vs-source conflation, but it belongs to the #1743 redesign or an explicit operator call. - `ASSURANCE_REGISTRY` — the 6 new commands need declared output contracts (#1272), a per-command product decision.
Problem
Every JSON conversation export packaged inside a
.zip(ChatGPT/Claude web exports) silently failed to ingest withFile or stream is not seekableand was skipped.process_zipopens each entry viazipfile.ZipExtFile(non-seekable). For individual-JSON entries the path isemit → _emit_individual → _iter_json_stream → iter_json_stream_with, which rewinds withhandle.seek(0)between its ijson multi-strategy attempts. A zip entry can't seek, so the parse raised and the file was dropped at the acquisition boundary. (_emit_groupedalready materialized toBytesIO; the individual path did not.)This is a real ingestion regression for zipped exports — surfaced once the suite could collect again (#1765) and confirmed by tracing the swallowed exception at
source_parsing.py:163.Solution
In
iter_json_stream_with, before the seeking strategies, materialize a non-seekable handle into aBytesIOonce (the function inherently requires seeking; bounded zip entries are safe to read fully). Added the missingimport io.Verification
Fixes the zip round-trip, raw-capture, multi-conversation-zip, BOM-in-zip, and partial-corruption cases.