[WRONG BRANCH] web-search: bound Anthropic sidecar SSE and error bodies to avoid unbounded buffering - #212
Conversation
|
Warning Review limit reached
Next review available in: 54 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Comment |
|
✅ Deterministic PR hygiene checks passed. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0538418c21
ℹ️ 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".
| if (rawFrame.length > ANTHROPIC_MAX_FRAME_CHARS) { | ||
| exceedLimit("anthropic sidecar SSE frame exceeded the safe size limit"); |
There was a problem hiding this comment.
Enforce the frame limit while buffering
When an upstream sends more than 1 MiB without a frame separator and keeps the stream open, this check never runs because processFrame is called only after \n\n or EOF. The parser therefore retains and repeatedly concatenates/scans the oversized frame until the 4 MiB body limit or sidecar timeout, defeating the intended per-frame ceiling and allowing unnecessary memory/CPU consumption; check the unterminated buffer after every decoded chunk and return the existing frame-limit error immediately.
AGENTS.md reference: src/AGENTS.md:L17-L17
Useful? React with 👍 / 👎.
⏳ DRAFT
What to do
Its title has been prefixed with |
Motivation
res.text()for non-2xx bodies, which allows a malicious or compromised upstream to exhaust proxy memory.Description
ANTHROPIC_MAX_SSE_BYTES,ANTHROPIC_MAX_FRAME_CHARS,ANTHROPIC_MAX_TEXT_CHARS, andANTHROPIC_MAX_SOURCESand enforce them inparseAnthropicSidecarSSEto bound total streamed bytes, per-frame size, accumulated answer length, and retained sources.res.text()on non-OK responses with the shared bounded readerreadBoundedResponseBodyand return a status-only fallback when the body is oversized or unavailable.tests/web-search-anthropic.test.tsthat exercise oversized SSE responses, oversized frames, overlong answer deltas, capped sources, and bounded non-success response bodies.Testing
bun test --timeout 20000 tests/web-search-anthropic.test.ts, and all tests in that file passed (15 pass).bun x tsc --noEmitandbun run privacy:scan, both of which completed successfully in the local run.bun run test), which exercised the test suite and showed the change did not regress the Anthropic web-search tests, but one unrelated external-provider discovery test (tests/grok-models-effort-list.test.ts) timed out in this environment due to external network/provider discovery dependencies.Codex Task