[WRONG BRANCH] fix(web-search): bound Exa response bodies - #326
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 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 |
|
✅ Deterministic PR hygiene checks passed. |
⏳ DRAFT
What to do
Its title has been prefixed with |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 794652493b
ℹ️ 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".
| }), | ||
| { abortSignal: linkedSignal.signal, label: "exa-web-search-sidecar" }, | ||
| ); | ||
| const bounded = await readBoundedResponseBytes(res, { |
There was a problem hiding this comment.
Guard the response body before starting the bounded read
When the client abort or timeout lands immediately after fetchWithResetRetry returns headers, readBoundedResponseBytes can observe the already-aborted signal and throw before acquiring or cancelling the response body. On Bun, that leaves the fetch body's native rejection unobserved and can surface as an unhandledRejection, despite this function returning a graceful error. Attach cancelBodyOnAbort(res.body, linkedSignal.signal) before this read and detach it in a finally, as the Gemini executor does.
AGENTS.md reference: src/AGENTS.md:L17-L17
Useful? React with 👍 / 👎.
Motivation
res.text()/res.json(), allowing a malicious or compromised Exa response to exhaust process memory/CPU.Description
readBoundedResponseBytesand theMAX_SIDECAR_RESPONSE_BYTESceiling before decoding or parsing any Exa response.<prefix> exceeded byte bound) before any JSON parsing or large-text handling.TextDecoderandJSON.parsethe guarded text (preserving the existing literal-key scrubbing and truncation behavior for error paths).tests/exa-web-search.test.ts).Testing
bun run test -- tests/exa-web-search.test.tsand all tests passed (11 passed, 0 failed).bun run typecheckandbun run privacy:scan, both completed successfully.bun run testworkflow and observed an unrelated environment-dependent failure intests/lab-live-probe.test.tsthat stopped the full-suite run, while the focused Exa tests remained green.Codex Task