Repository navigation
fix(egress): Skip body reading for OPTIONS requests - #2199
sentry[bot] wants to merge 3 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
The OPTIONS part is right. JUNIOR-DQ is a sandbox OPTIONS request (curl) that failed in requestBodyBytes, and sandbox egress already treats OPTIONS as a read.
The request.bodyUsed guard was not safe, though. It made a used body look like no body for every method. A POST with a used body would then go upstream with credentials and no payload. #2068 added the 500 to stop exactly that, and its integration test (returns a Junior egress error instead of forwarding an unreadable body) fails with this guard (202 instead of 500).
I pushed f8be21f:
- Removed the
bodyUsedguard and kept theOPTIONSskip. - Moved the test from the component suite to
tests/integration/sandbox-egress-proxy.test.ts, next to the unreadable-body case. It sends anOPTIONSrequest with a used body and checks that the proxy forwards it with no body. Onmainit gets a 500, and with this change it passes.
Local: both sandbox-egress-proxy suites pass (58/58), and tsc --noEmit, oxlint, and the test-architecture check pass. CI is running on the new head.
There was a problem hiding this comment.
Ready for a human merge at f8be21f.
- The change only skips the body read for
OPTIONS. Writes with a used body still get the Junior egress 500 from #2068, so the Bugbot finding about thebodyUsedguard no longer applies. - The new integration test (
forwards an OPTIONS request without reading its used body) gets a 500 onmainand passes here.returns a Junior egress error instead of forwarding an unreadable bodystill passes. - CI is green on this head, including
test / junior integration,test / junior component,check / types,lint / workspace, CodeQL, Warden, andci / required.
f8be21f to
65a4c0d
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 65a4c0d. Configure here.
There was a problem hiding this comment.
Still ready for a human merge at 081f01e. The head moved after my earlier note. The source fix is the same: requestBodyBytes skips the body read only for OPTIONS. A write with a used body still gets the Junior egress 500 from #2068.
The OPTIONS test is now in the component suite again. It sends a preflight with an empty body and uses that body before the proxy runs. So the stream is not null, and the test fails if the OPTIONS guard is removed. That covers the later Bugbot note about the test.
Local run at 081f01e:
- Both
sandbox-egress-proxysuites (integration and component) pass, 58/58. That includesreturns a Junior egress error instead of forwarding an unreadable body. - With the
OPTIONSline removed, the new test fails.
CI is green at this head, including ci / required. Both review threads are resolved.

A sandbox
OPTIONSrequest through the egress proxy can reachexecuteCredentialedEgressRequestwith a body stream that is already used.requestBodyBytesthen callsrequest.arrayBuffer(), which throwsTypeError: Body is unusable: Body has already been read. The proxy logs the exception and returns a 500.Changes
requestBodyBytesinpackages/junior/src/chat/egress/credentialed.tsskips the body forOPTIONS, likeGETandHEAD. Sandbox egress already treatsOPTIONSas a read method.tests/integration/sandbox-egress-proxy.test.tssends anOPTIONSrequest with a used body. It checks that the proxy forwards it without a body.Fixes JUNIOR-DQ
@sentry <feedback>: Autofix iterates on these changes@sentry stop iterating: Autofix stops iterating on this runThis PR was automatically generated by Sentry. You can adjust this setting at any time.
via Junior system actor
junior.--
View Junior Session [Sentry]