Skip to content

fix(server): forward the body of a GET or other request that declares one - #2518

Open
acodercat wants to merge 2 commits into
opensandbox-group:mainfrom
acodercat:fix/server-proxy-get-with-body
Open

acodercat wants to merge 2 commits into
opensandbox-group:mainfrom
acodercat:fix/server-proxy-get-with-body

Conversation

@acodercat

Copy link
Copy Markdown
Contributor

The server proxy (/sandboxes/{id}/proxy/{port}/...) streams the request body to the sandbox only for POST, PUT, PATCH and DELETE. For any other method it sends no body, but it still forwards the client's Content-Length, which is not a hop-by-hop header.

So a GET with a body, as used by Elasticsearch-style search APIs, fails on current main. The backend receives content-length: 7 and no body, httpx raises "Too little data for declared Content-Length", that ends in the generic handler, and the client gets 500 GENERAL::UNKNOWN_ERROR.

Summary

  • The proxy now also streams the body when the request declares one, with Content-Length or Transfer-Encoding, as RFC 9112 defines it. POST, PUT, PATCH and DELETE are streamed as before.
  • A request without a body, for example a plain GET, is unchanged and still sends no body.

Testing

  • Not run (explain why)

  • Unit tests

  • Integration tests

  • e2e / manual verification

  • New test_proxy_forwards_get_request_with_body: a GET with a body must forward its Content-Length together with the body. It fails on current main.

  • Checked by hand against a raw-socket backend with the real httpx.AsyncClient: current main returns 500, and with this change the backend gets the body and the client gets 200.

  • The full server suite passes (2698 passed). ruff and pyright are clean.

Breaking Changes

  • None
  • Yes (describe impact and migration path)

Checklist

  • Linked Issue or clearly described motivation
  • Added/updated docs (if needed)
  • Added/updated tests (if needed)
  • Security impact considered
  • Backward compatibility considered

… one

The proxy streamed the request body only for POST, PUT, PATCH and
DELETE, but forwarded Content-Length for every method. A GET with a body
(Elasticsearch-style search, for example) reached the backend with a
Content-Length and no body, httpx failed with "Too little data for
declared Content-Length", and the client got a 500.

Also stream the body when the request declares one with Content-Length
or Transfer-Encoding. Requests without a body are unchanged.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T08:43:24.639877Z 8890be3 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added component/server size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Oct 31, 2026
Move the condition into _request_has_body, next to the other proxy
helpers, so the call site reads as what it decides.
@github-actions github-actions Bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Oct 31, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/server size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant