Skip to content

fix(google): bound embedding batch file upload error body read - #103306

Closed
ZOOWH wants to merge 3 commits into
openclaw:mainfrom
ZOOWH:fix/google-embedding-error-body-file
Closed

ZOOWH wants to merge 3 commits into
openclaw:mainfrom
ZOOWH:fix/google-embedding-error-body-file

Conversation

@ZOOWH

@ZOOWH ZOOWH commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

submitGeminiBatch() reads the full file-upload error response body via
fileRes.text() on non-OK upload failures with no size limit.

Why This Change Was Made

Replace the unbounded fileRes.text() with assertOkOrThrowProviderError() —
the canonical bounded provider error helper — so error body consumption is
capped at 16 KiB and structured error metadata is preserved.

User Impact

Before: unbounded error body read, potential memory exhaustion on large
error responses
After: bounded at 16 KiB via assertOkOrThrowProviderError

Evidence

Branch: fix/google-embedding-error-body-file | Base: upstream/main

Real behavior proof

Loopback proof: a local HTTP server streams a 4 MiB 503 JSON error response
on the upload endpoint. assertOkOrThrowProviderError (the exact helper used
in the fix) reads at most 16 KiB, cancels the stream, and throws a structured
ProviderHttpError:

$ node --import tsx scripts/proof/gemini-file-upload-error-loopback.mjs

// Server sends 503 with ~4 MiB streaming JSON body.
// assertOkOrThrowProviderError reads at most 16384 bytes.
// Error type: ProviderHttpError
// statusCode: 503
// errorBody: bounded (server sent 11 chunks, 0.7 MiB)

✅ Bounded: error body capped at 16 KiB despite 4 MiB server response.

Regression tests

$ node scripts/run-vitest.mjs extensions/google/embedding-batch.test.ts

 ✓ bounds a non-OK file-upload error response and cancels the stream (#103306)
 ... 5 more passing ...

 Test Files  1 passed (1)  Tests  6 passed (6)

Diff summary

extensions/google/embedding-batch.ts | 5 +---

What was not tested: live Google API integration (blocked by network proxy).

  • I understand what the code does
  • Change is focused and does not mix unrelated concerns

@ZOOWH
ZOOWH force-pushed the fix/google-embedding-error-body-file branch from 0b9a122 to 5bf7d01 Compare July 10, 2026 05:59
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jul 10, 2026
@clawsweeper

clawsweeper Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 10, 2026, 2:29 PM ET / 18:29 UTC.

Summary
The PR routes Gemini embedding batch file-upload failures through the shared bounded provider-error helper, adds an oversized non-OK regression through the production entry point, and adds a standalone loopback proof script.

PR surface: Source -2, Tests +28, Other +130. Total +156 across 3 files.

Reproducibility: yes. at source level: current main unconditionally reads the complete failed upload response, and the PR regression reaches that branch through runGeminiEmbeddingBatches. This read-only review did not independently execute the PR code.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: vector/embedding metadata: extensions/google/embedding-batch.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: canonical
Canonical: #103306
Summary: This PR is the canonical candidate for the file-upload branch; a sibling PR fixes a separate raw error-body read in the same Gemini batch workflow.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦐 gold shrimp
Patch quality: 🦞 diamond lobster
Result: blocked until stronger real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Post redacted loopback terminal output through runGeminiEmbeddingBatches showing the oversized 503 upload response is bounded and cancelled.
  • Refresh the branch against current main before final review.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The terminal proof invokes the shared helper directly rather than the changed runGeminiEmbeddingBatches upload path; add redacted exact-workflow loopback output, then update the PR body to trigger re-review or ask a maintainer to comment @clawsweeper re-review, with private endpoints, keys, IPs, and other sensitive details removed.

Risk before merge

  • [P1] The submitted real-HTTP proof demonstrates the shared helper but leaves the changed Gemini upload workflow unproven outside a stubbed-fetch test.
  • [P1] The branch is behind current main and needs a final refresh before landing.

Maintainer options:

  1. Decide the mitigation before merge
    Keep the shared-helper runtime change and focused regression, provide redacted loopback output that reaches the failed upload through runGeminiEmbeddingBatches, and refresh the branch before owner review; retain the proof script only if maintainers want it as durable repository tooling.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] No automated code repair is indicated; the remaining actions are contributor-supplied exact-workflow proof, branch refresh, and normal review by the related Google/provider HTTP owners.

Security
Cleared: The diff changes no dependencies, workflows, permissions, package resolution, publishing, or secret access and reduces exposure to oversized or sensitive provider error bodies.

Review details

Best possible solution:

Keep the shared-helper runtime change and focused regression, provide redacted loopback output that reaches the failed upload through runGeminiEmbeddingBatches, and refresh the branch before owner review; retain the proof script only if maintainers want it as durable repository tooling.

Do we have a high-confidence way to reproduce the issue?

Yes at source level: current main unconditionally reads the complete failed upload response, and the PR regression reaches that branch through runGeminiEmbeddingBatches. This read-only review did not independently execute the PR code.

Is this the best way to solve the issue?

Yes for the runtime fix: the shared provider HTTP helper is the narrow canonical owner for bounded reads, cancellation, redaction, and structured errors. The remaining blocker is exact-workflow real behavior proof, not the implementation shape.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against b56bad33f2fb.

Label changes

Label justifications:

  • P2: The PR fixes an unbounded provider error-response read in one Google embedding batch path with limited blast radius.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦞 diamond lobster.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The terminal proof invokes the shared helper directly rather than the changed runGeminiEmbeddingBatches upload path; add redacted exact-workflow loopback output, then update the PR body to trigger re-review or ask a maintainer to comment @clawsweeper re-review, with private endpoints, keys, IPs, and other sensitive details removed.
Evidence reviewed

PR surface:

Source -2, Tests +28, Other +130. Total +156 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 2 4 -2
Tests 1 30 2 +28
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 130 0 +130
Total 3 162 6 +156

What I checked:

Likely related people:

  • hugenshen: Introduced the bounded Gemini embedding-batch response work and the central test suite now extended by this PR. (role: introduced related behavior; confidence: high; commits: 91297bf42082; files: extensions/google/embedding-batch.ts, extensions/google/embedding-batch.test.ts)
  • steipete: Introduced shared provider HTTP error parsing and moved memory embeddings into provider plugins. (role: shared helper and owner-boundary contributor; confidence: high; commits: 2c516fe5169c, 77e6e4cf87f7; files: src/agents/provider-http-errors.ts, extensions/google/embedding-batch.ts)
  • vincentkoc: Hardened provider response reader cancellation and recently maintained the memory-host remote HTTP boundary. (role: recent shared HTTP contributor; confidence: high; commits: e802fb8a9fbb, 036686ab9536; files: src/agents/provider-http-errors.ts, packages/memory-host-sdk/src/host/remote-http.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (3 earlier review cycles)
  • reviewed 2026-07-10T09:58:46.799Z sha 5bf7d0160627a0408a5d7f32d06c8648fdcd3150 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-10T12:10:53.963Z sha 5bf7d0160627a0408a5d7f32d06c8648fdcd3150 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-10T14:19:40.921Z sha 9abbd5a02089bcc9e1d35a36fddc53a6bd681d81 :: needs real behavior proof before merge. :: none

@ZOOWH

ZOOWH commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Added loopback HTTP proof: real server returns 400 with sensitive body → assertOkOrThrowProviderError produces sanitized ProviderHttpError with redacted values and structured metadata.

@clawsweeper

clawsweeper Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 10, 2026
@ZOOWH

ZOOWH commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Same proof gap as #103472: the existing test used status 200 (success path) which never reached the changed assertOkOrThrowProviderError branch. Added a non-OK (503) oversized response test that exercises the exact error path — verifies bounded read, cancellation, and structured error via runGeminiEmbeddingBatches.

node scripts/run-vitest.mjs extensions/google/embedding-batch.test.ts
Tests  5 passed (5)

@clawsweeper

clawsweeper Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

ZOOWH added 3 commits July 11, 2026 01:53
…rror

Replace manual response.text() + throw Error with the canonical
assertOkOrThrowProviderError which provides bounded reads, redaction,
and structured ProviderHttpError metadata.

Ref: openclaw#102953
…law#103306)

The existing file-upload test used status 200 (success path) which never
exercised the assertOkOrThrowProviderError branch. Add a non-OK (503)
oversized response test that validates bounded read and cancellation
through the exact error path this PR changes.
Local HTTP server returns oversized 503 on the upload endpoint.
assertOkOrThrowProviderError reads at most 16 KiB and returns a
bounded ProviderHttpError — same pattern as the accepted proof
in openclaw#103472 for the batch-create sibling path.
@ZOOWH

ZOOWH commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Added loopback proof (local HTTP server -> assertOkOrThrowProviderError against real 4 MiB streaming 503 response). Same pattern accepted for the sibling batch-create path in #103472. Rebated onto main.

$ node --import tsx scripts/proof/gemini-file-upload-error-loopback.mjs

// Error type: ProviderHttpError
// statusCode: 503
// errorBody: bounded (server sent 11 chunks, 0.7 MiB before client cancelled)

OK Bounded: error body capped at 16 KiB despite 4 MiB server response.

@ZOOWH
ZOOWH force-pushed the fix/google-embedding-error-body-file branch from 9abbd5a to 5061b1a Compare July 10, 2026 17:54
@clawsweeper

clawsweeper Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@steipete

Copy link
Copy Markdown
Contributor

Superseded by #103472, now landed as fb702e5.

The landed rewrite includes this bounded Google batch-upload error path, plus shared bounded JSONL handling, structured/redacted diagnostics, full Google upload/create/poll/download lifecycle coverage, and exact-head CI proof. Thank you @ZOOWH for identifying and proving the original gap.

If a distinct remaining case reproduces on current main, please open a focused report with the endpoint behavior and exact response shape.

@steipete steipete closed this Jul 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: google P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants