Skip to content

fix(gateway): refuse over-limit request bodies with 413 - #256

Merged
outofcoffee merged 4 commits into
mainfrom
worktree-gateway-1mb-completion
Oct 5, 2026
Merged

outofcoffee merged 4 commits into
mainfrom
worktree-gateway-1mb-completion

Conversation

@outofcoffee

Copy link
Copy Markdown
Collaborator

The gateway now answers a completion request body over its limit with a 413 that names the limit and the flag, instead of cutting it off at 1 MiB and failing with a misleading 400.

Summary

  • Read the request body with http.MaxBytesReader, so an over-limit body is an error and not a silent truncation.
  • Answer an over-limit body 413, naming the limit in bytes and --max-request-bytes.
  • Raise the default limit from 1 MiB to 64 MiB, and add --max-request-bytes to spinloop gateway (values below 1 fail at startup).
  • Never forward a body that was not read in full: any failed read is refused before routing.
  • Document the flag and a short request size section in docs/commands/gateway.md.
  • Add the request body limit requirement to the fleet-gateway spec through the gateway-max-request-bytes OpenSpec change, which is not yet archived.

Fixes #240

spinloop-agent added 3 commits October 5, 2026 20:13
The gateway cut completion bodies off at 1 MiB, so a larger body failed as malformed JSON. The body is now read through http.MaxBytesReader, an over-limit one is answered 413 naming --max-request-bytes, and the default rises to 64 MiB. Fixes #240
@outofcoffee outofcoffee added the bug Something isn't working label Oct 5, 2026
@outofcoffee
outofcoffee marked this pull request as ready for review October 5, 2026 19:36
@outofcoffee
outofcoffee merged commit d038a2b into main Oct 5, 2026
5 checks passed
@outofcoffee
outofcoffee deleted the worktree-gateway-1mb-completion branch October 5, 2026 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: the gateway rejects any completion request over 1 MiB with a misleading 400

1 participant