Repository navigation
fix(google): bound embedding batch response reads - #98692
ly85206559 wants to merge 1 commit into
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 6, 2026, 12:15 PM ET / 16:15 UTC. Summary PR surface: Source +81, Tests +289. Total +370 across 2 files. Reproducibility: yes. at source level: current main and v2026.6.11 still use unbounded Google batch upload/create error-body reads and completed-output response.text() downloads. I did not run a current-main OOM reproduction because this review was read-only. Review metrics: 2 noteworthy metrics.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Land the bounded streaming parser once maintainers accept or adjust the 4 MiB per-line and submitted-record-count budgets while preserving bounded error reads and early stream cancellation. Do we have a high-confidence way to reproduce the issue? Yes at source level: current main and v2026.6.11 still use unbounded Google batch upload/create error-body reads and completed-output response.text() downloads. I did not run a current-main OOM reproduction because this review was read-only. Is this the best way to solve the issue? Yes for the fix shape: bounded error reads plus streaming JSONL at the Google batch output-file boundary is the narrow provider-local repair. The exact fail-closed budgets are a maintainer compatibility choice, not an automated code defect. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e580ed2f7105. Label changesLabel justifications:
Evidence reviewedPR surface: Source +81, Tests +289. Total +370 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (4 earlier review cycles)
|
|
@clawsweeper re-review I updated the PR body to remove the hidden BOM that made the Real behavior proof check miss the authored sections, and added loopback HTTP proof for the production Gemini embedding batch path. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
6ff4d1d to
0ac23eb
Compare
|
@clawsweeper re-review Current head is 0ac23eb0ad5987889105b014094f5e5e5d23a2e2. I updated the PR body with loopback HTTP proof, including the valid JSONL path and oversized-line cancellation path, and the Real behavior proof check is green. Please re-review the current head. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
0ac23eb to
5371044
Compare
5371044 to
fa3f0c5
Compare
|
Superseded by #103472, now landed as The landed rewrite preserves this PR's core safety goals—bounded Google response reads, streaming JSONL output, record/byte budgets, early cancellation, and unknown/duplicate response handling—while moving the generic contract into the shared memory host SDK and applying it consistently to Google, OpenAI, and Voyage. Exact-head focused tests, a real loopback Google lifecycle, and hosted CI are green. Thank you @ly85206559 for the original report and implementation work. If a distinct remaining case reproduces on current main, please open a focused report with the exact provider output and batch size. |
What Problem This Solves
Fixes a sibling OOM risk to #98554 in Gemini/Google embedding batch handling. The Gemini batch upload/create error paths and completed output download path still had raw response body reads. A faulty or hostile Google-compatible endpoint could stream oversized error bodies, an oversized JSONL record, or extra/blank output records after a batch completed.
Why This Change Was Made
The Google embedding batch code now uses the shared bounded provider HTTP readers for upload/create error bodies, and streams completed JSONL output one record at a time instead of buffering the whole file.
The output reader keeps valid large batch outputs working by allowing files larger than the provider text cap, while bounding the unsafe shapes:
readResponseTextLimitedcustom_idrows are ignored instead of being stored in the result mapThis follows the same invariant as the recent OpenAI embedding batch hardening: large valid JSONL output should stream successfully, but malformed single-record or unbounded provider output must be cancelled early.
User Impact
Users running large Gemini embedding batches can still process valid large result files, and a bad provider response cannot grow gateway memory through unbounded response buffering or unlimited small output rows.
Evidence
Loopback transport proof: I ran the production
runGeminiEmbeddingBatchespath against a local HTTP server on127.0.0.1. This uses the realwithRemoteHttpResponse/fetchWithSsrFGuardpath, real HTTPResponsestreams, and no mockedfetch.Targeted unit proof: the tests drive
runGeminiEmbeddingBatchesthrough upload, batch create, status polling, and output download using realResponsestreams passed through the productionwithRemoteHttpResponsecallback shape. They cover the large-output and record-budget cases that are cheaper to validate deterministically in-process.Notes for reviewers:
extensions/google/embedding-batch.tsand its tests.AI-assisted: built with Codex. I understand the change: it replaces unbounded Gemini batch response reads with bounded error reads plus a streaming JSONL output reader capped by per-record byte size and submitted record count.