Skip to content

rpc: a method states its largest request with max_request_bytes, and Envoy refuses a larger one before the service reads it - #82

Merged
tudor-pop merged 1 commit into
masterfrom
80-method-max-request-bytes
Dec 3, 2026
Merged

tudor-pop merged 1 commit into
masterfrom
80-method-max-request-bytes

Conversation

@tudor-pop

Copy link
Copy Markdown
Contributor

Closes #80

A method of an rpc entry can state the largest request message it takes: max_request_bytes in a methods file, or the field of that name in the message of the option rpc.proto names. A file without the key renders as release 2.3.1 did.

  • Envoy turns on its buffer filter on the method's route, with the limit and the 5 bytes of the gRPC prefix: a larger body is answered 413 (a gRPC call: grpc-status 2) before the service reads any of it.
  • Five routes on the method's path come before its own: a GET is answered 405, a request of any other method whose path carries a query string 400, and a request in which any value of grpc-encoding, content-encoding or connect-content-encoding is other than identity is answered 415, also when the header is written more than once.
  • The five routes carry the method route's rate-limit entry and its question for the auth check, so a refused request is counted and asked about as the method's own call would be.
  • A file is refused when a route written before the rpc entry takes the path of a method with a limit, and when a method that takes a stream of requests sets the limit.
  • nginx and HAProxy refuse the key; the format's known keys, the schema, the examples and the docs name it. docs/limits.md states what the limit holds and what it does not (a body without a frame prefix may be up to 5 bytes over; over HTTP/2 a body that arrives whole in one frame is not counted).
  • The conformance battery has a new scenario of 18 rows on Envoy 1.40.2.
  • The README and the docs name release 2.4.0, which is tagged on this merge.

One independent review in two parts (the code and the tests; 185 request forms sent to a local Envoy), one round of corrections built tests first, and a second pass of the request forms at the corrected code with no important finding. The findings and what was changed for each are in the issue.

Run locally: go test ./... at this tree with no failing package; and, one commit earlier, before three doc sentences changed and with the rendered output the same, scripts/validate-envoy.sh on all 26 examples and the conformance battery's request-limit (18 rows) and full (634 rows) scenarios on Envoy 1.40.2. The branch is squashed onto master with its tree unchanged.

…, and Envoy refuses a larger one before the service reads it (Part of #80)

A method of an rpc entry can state the largest request message it takes, in
bytes: `max_request_bytes` in a methods file, or the field of that name in the
message of the option `rpc.proto` names. A whole number from 1 to 4294967290;
a method that does not write it has no limit, and a file without the key
renders as release 2.3.1 did.

The Envoy output, for each method with a limit, writes five routes on the
method's path before its own:
- a GET is answered 405 with `allow: POST`,
- a request of any other method whose path carries a query string is
  answered 400, because the Connect bridge builds a message from the query of
  a request that has no body and the filter counts no byte of it,
- a request in which any value of grpc-encoding, content-encoding or
  connect-content-encoding is other than identity is answered 415, also when
  the header is written more than once (one regular expression per header,
  no inverted match), because the filter counts the bytes it receives and a
  compressed message is inflated only in the service.
The method's own route turns on the buffer filter with the limit and the 5
bytes of the gRPC prefix, so a larger body is refused before the service reads
any of it. The five refusal routes carry the method route's metadata and its
question for the auth check, so a refused request takes a token from the rpc
entry's rate limit and is asked about as the method's own call would be.

A file is refused when a route written before the rpc entry takes the path of
a method with a limit, because that limit would never apply, and when a
method that takes a stream of requests sets the limit, because the filter
holds a request until it ends.

The nginx and HAProxy outputs refuse the key.

docs/limits.md states what the limit holds and what it does not: a Connect
unary call the bridge does not convert carries no prefix, so its body may be
up to 5 bytes over the limit, and over HTTP/2 a body that arrives whole in
one frame is not counted. The conformance battery checks each answer on
Envoy 1.40.2 in a new scenario of 18 rows.

The README and the docs name release 2.4.0.
@tudor-pop
tudor-pop merged commit a166a4c into master Dec 3, 2026
1 check passed
@tudor-pop
tudor-pop deleted the 80-method-max-request-bytes branch December 3, 2026 05:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A method cannot state its largest request, so an RPC route passes a body of any size to its service

1 participant