Repository navigation
Description
An RPC route passes a request body of any size to its service: neither a methods file nor a method's .proto option
can say how large a method's request may be, so a service that accepts large messages for one method reads a message
of that size for every method behind the gateway. Envoy's buffer filter can refuse a larger body per route, before
the service reads any of it, but proxyfile writes no such limit.
What changes:
- A method may carry
max_request_bytes: the largest request message, in bytes as serialized, the route passes on.
It is read from a methods file (rpc.methods[].max_request_bytes, an integer from 1 to 4,294,967,290) and, under
rpc.proto, from a field of that name in the option's message, which must hold oneuint32when the message has
it (asreportsis read today; any other field stays untouched). - The RPC table writes
"max_request_bytes": Non the rows of the methods that carry one, and nothing on the others. - The Envoy output lists
envoy.filters.http.bufferonce, disabled, right before the Connect bridge (before the
router without one), with the smallest route's value, and turns it on for each limited method's route with
BufferPerRouteN + 5 (the gRPC prefix). Measured on Envoy 1.40.2: a message of exactly N passes in Connect and in
gRPC over HTTP/1.1, and N + 1 is refused, with 413text/plainPayload Too Largeto a Connect call and
grpc-status 2 with that message to a gRPC call. - The buffer filter counts the bytes it receives, so it cannot bound what a compressed message inflates to: gzip
writes 128 MiB of zeros in about 130,500 bytes, under a limit of 131,072. Right before each limited method's route,
the Envoy output therefore writes two routes on the same path that answer 415 to a request whosegrpc-encodingor
content-encodingis present and notidentity(measured on Envoy 1.40.2: a Connect call gets 415, a gRPC call
grpc-status 2, and the backend sees neither). - nginx and HAProxy refuse the key in this version, as
ask_unlistedis refused: "not written by this version's
nginx generator; leave max_request_bytes out, or render it for envoy" (and the HAProxy form). A file without the key
renders byte for byte as 2.3.1 does, for every target. - Tests: the RPC table with and without the key; the option field read, absent and of the wrong type; the refusal by
nginx and HAProxy through a methods file and throughrpc.proto; the full example before the key rendered byte for
byte as 2.3.1; the filter entry, the per-route value and the two 415 routes; a conformance scenario on Envoy (exactly
N passes, N + 1 refused in each form, compressed refused, the stub backend sees only the passing call); the core key
count from 131 to 132. - Docs:
docs/rpc.md,docs/limits.md,docs/portability.md, a "After 2.3.1" section indocs/format.md, and the
release named inREADME.mdanddocs/editors.md, which still say v2.2.0. Released as v2.4.0.
Consumers
- Every existing Proxyfile and every file it writes: with the key absent the Envoy, nginx and HAProxy outputs and the
RPC table are byte-identical to 2.3.1's, proven by a golden of the full example before the key and by the examples
check (go test -count=1 ./... 2>&1 | grep -E '^(ok|FAIL)'). - A reader of the RPC table that refuses unknown keys must accept
max_request_bytesbefore it reads a table written
from a file that uses the key; a table from a file without it is unchanged. - The JSON schema (
schema/proxyfile.schema.json) and the key tables of the README and docs, rewritten by
go test ./internal/format -run TestSchemaIsCurrent -update;examples/full, the files that write every key, use it. - An option message that already has a field named
max_request_bytesof another type: refused with a problem at the
option, where 2.3.1 left it alone; noted in "After 2.3.1".
Open tickets checked: the names max_request, request body, buffer filter, request size and largest request over this repository's open issues found none (2 issues open, #74 and #77, both about other things).
Lane
FULL: it changes the file format's schema and the RPC table other programs read, and decides which requests a route
refuses before its service.
Scope update (3 December 2026)
A review of the design found two request forms the routes described above do not cover:
- A Connect GET carries its message in the query string. Envoy's buffer filter does nothing for a request without a body, so the limit does not apply to it, and a
compressionparameter is not a request header. - A request in the Connect streaming form names its compression in
connect-content-encoding.
So the Envoy output for a method with max_request_bytes also writes, before the method's route: one route that answers 405 to a GET (a method with a limit takes its message in a request body only), and a third 415 route for connect-content-encoding. A file without the key still renders as 2.3.1 does.
Added to the acceptance: tests for the route order and the two new routes, conformance rows for a Connect GET (405) and a compressed streaming-form request (415), and the docs say that over HTTP/2 a body that arrives whole in one frame is not counted by Envoy's buffer filter.
Scope update (3 December 2026): a request with a query string
A probe of the output found one more request form the routes above do not cover. Envoy's Connect bridge builds a message from the query string of any request that ends with its headers, whatever its method, and the buffer filter does not count a request without a body. So a POST, PUT or DELETE with no body and a message in its query is not held to the method's limit.
The Envoy output for a method with max_request_bytes therefore writes one more route, right after the GET route: a request whose :path carries a query string is answered 400. A gRPC or Connect call with a body carries no query, so the rule changes nothing for them. The order before the method's route is: 405 on GET, 400 on a query string, then the three 415 routes. A file without the key still renders as 2.3.1 does.
Added to the acceptance: a test for the new route and its place in the order, conformance rows for a POST and a DELETE with no body in the Connect query form (400, nothing sent to the service), and the docs say that a method with a limit takes its message in a request body only.
Activity
test(rpc): a method's request limit is refused above 4294967290 from …
feat(rpc): a method's max_request_bytes, read from a methods file or …
feat(envoy): a method with max_request_bytes gets the buffer filter o…
test(envoy): a limited method's route is preceded by a 405 for a GET …
feat(envoy): a limited method's route is preceded by a 405 for a GET …
test(envoy): a limited method's path refuses a query string with 400,…
feat(envoy): a limited method's path refuses a query string with 400,…
test(envoy): refusal routes carry the method route's data, one matche…
feat(envoy): the refusal routes carry the method route's metadata and…
feat(rpc): a route before the rpc entry that takes the path of a meth…
feat(protofiles): a method that takes a stream of requests and sets m…
docs(limits): what the request limit holds, for a header written twic…
docs(rpc): the short rule names the body with a frame prefix over HTT…
feat(rpc): a method states its largest request with max_request_bytes…
tudor-pop commentedon Dec 3, 2026
Review of the branch before its pull request
One independent review in two parts on the pushed branch, one round of corrections built tests first, then a second pass by the second reviewer at the corrected code. Example names as in the docs (
shop.v1.CartService/AddItem, a limit of 2,048 bytes).Part 1: the code and the tests
One important point, three minor ones and three notes.
docs/rpc.mdstated the limit without the HTTP/2 one-frame exception; no test rendered the refusal routes of a limited method without the Connect bridge; one test comment named a limit its rows do not use. All three corrected.docs/rpc.md), and two small code comments.Part 2: request forms sent to a local Envoy 1.40.2
185 request forms, with a stub behind the proxy and, for the compressed forms, a real gRPC server. Three important points and three minor ones.
identity, was not refused. The first form of the rule was an inverted exact match, and Envoy 1.40.2 matches each value of a repeated header on its own, so a request withgrpc-encoding: identityandgrpc-encoding: gzipon two lines went on to the method's route, and the server behind it inflated the message past the limit. Corrected: one regular expression per header that matches any value other thanidentity, with no inverted match. It answers the same whether the values arrive on separate lines or joined.connect-protocol-version), or any Connect unary call in a file without the bridge, carries no prefix, so a body of up to the limit and 5 bytes reaches the service. This is not refused;docs/limits.mdnow states it, and two conformance rows hold it (the limit and 5 bytes: served; the limit and 6 bytes: 413).prefix, apathor apattern, whatever the route's other conditions:route "cart" is written before the rpc entry and takes the path of shop.v1.CartService/AddItem, so that method's max_request_bytes would not apply; write the route after the rpc entry.rpc.proto, such a method that sets the field is refused.docs/limits.md: a Connect body 1 to 5 bytes over the limit may be seen by the service as a call opened and reset, with no byte of the message; "any compressed request" was wider than what the routes refuse (they refuse a request that names a compression other thanidentity); a gRPC-Web text body is base64, so its message is at most about three quarters of the limit.The second pass, at the corrected code
No important finding.
identityand no header at all are served.grpc-status8 for a gRPC call) with no check call. An action a caller wrote into its own request reached the check in 0 of 7 calls.method: GET, a rewrite,auth: off, an include, a concatenation and two rpc entries were each refused.docs/limits.mdstates (4 without a frame prefix over HTTP/1.1, up to 5 bytes over; 8 over HTTP/2 in one frame).docs/rpc.mdread as if the frame-prefix case were an HTTP/2 matter;docs/rpc.mddid not say a gRPC call gets the refusal asgrpc-status2; and a call opened and reset with no byte of the message also happens over HTTP/2.Not verified by the review: the proxy's peak memory under many held requests, and a live server-streaming call through a limited method.
feat(rpc): a method states its largest request with max_request_bytes…
tudor-pop commentedon Dec 3, 2026
Shipped in release v2.4.0.
proxyfile.schema.jsonandchecksums.txt.max_request_bytes. The rendered Envoy configuration refuses a larger request, a compressed one, aGETand a request with a query string on that method's path before the service reads anything, and counts each refusal as a call of that method.docs/rpc.mdanddocs/limits.mdstate what each kind of caller is answered and what the limit does not cover.