Skip to content

[EAI-8489]: Raise ai-gateway body-authz request-body cap to 4MiB - #834

Merged
johnl-amd merged 2 commits into
release/v2.4.xfrom
EAI-8489-body-authz-cap-v24x
Sep 3, 2026
Merged

[EAI-8489]: Raise ai-gateway body-authz request-body cap to 4MiB#834
johnl-amd merged 2 commits into
release/v2.4.xfrom
EAI-8489-body-authz-cap-v24x

Conversation

@johnl-amd

Copy link
Copy Markdown
Contributor

Backport of #832 (plus the follow-up commit on that branch) to release/v2.4.x. Cherry-picked with -x, both commits preserved.

  • Parameterizes bodyToExtAuth.maxRequestBytes on the ai-gateway-default-deny SecurityPolicy as aiGateway.bodyAuthMaxRequestBytes, default 4MiB. The upstream 64KiB default returns HTTP 413 and skips authorization entirely (ahead of failOpen), so every large request on the header-less path was rejected before reaching a model.
  • Drives both charts from global.aiGateway.bodyAuthMaxRequestBytes in root/values.yaml, so the gateway-scoped policy and the per-model catch-all policies stamped by ai-gateway-discovery cannot drift. The catch-all policies are rule-scoped and override the gateway-scoped one per route, so a mismatch is silently decided by whichever is lower.
  • Renders through int64 and fails the template on a non-positive value. A bare number in a values file is a float64, so an unguarded render emits 4.194304e+06, which int64 casts to 0 and would publish maxRequestBytes: 0.

Needs the matching ai-gateway-discovery change, silogen/core#4520, to be effective on any cluster with models deployed.

https://jira.amd.com/browse/EAI-8489

How to test

Send a header-less inference request larger than 64KiB (model in the JSON body, no x-ai-eg-model header) with a valid API key. It returned 413 before and should now be served. Verified on app-dev against MiniMaxAI/MiniMax-M2.5: 40KB and 200KB return 200, 5MB returns 413 at the new ceiling, and no key returns 401.

fredespi and others added 2 commits September 3, 2026 13:48
The body-aware extAuth on ai-gateway buffers the request body at
maxRequestBytes=64KiB before authorizing header-less (model-in-body)
requests. Envoy returns 413 for any larger body (skipping auth, and
overriding failOpen), so standard OpenAI/Anthropic clients sending
200KB-2MB contexts are rejected gateway-wide, for every model.

Parameterize as aiGateway.bodyAuthMaxRequestBytes (default 32MiB) so
large-context and image-bearing inference turns are not rejected; the
value sits under the 50Mi connection bufferLimit and is tunable per env.

EAI-8489

(cherry picked from commit 758ee8b)
Follow-up on the 32MiB commit on this branch.

- 4MiB, not 32MiB. The ai-gateway-discovery authz pod that receives the
  buffered body is capped at limits.memory 256Mi, and an in-flight
  header-less request is held both by Envoy and by that handler, so 32MiB
  is more than the current deployment can absorb. 4MiB covers a ~200k-token
  turn (~1MB) with headroom.

- Drive both charts from global.aiGateway.bodyAuthMaxRequestBytes. The
  gateway-scoped policy here is not the only cap on the header-less path:
  ai-gateway-discovery stamps per-model catch-all SecurityPolicies
  (sectionName route-not-found) that are rule-scoped and override this one
  per route. They carry their own ceiling, so the two must move together.

- Render through int64 and fail on a non-positive value. A bare number in
  a values file is a float64, so the root wiring emitted 4.194304e+06 and
  int64 casts that to 0, which would have published maxRequestBytes: 0
  instead of failing.

The matching ai-gateway-discovery change lands in silogen/core.

(cherry picked from commit b4a3d54)
@johnl-amd
johnl-amd requested a review from a team as a code owner September 3, 2026 11:50

@Q-Dub Q-Dub left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@johnl-amd
johnl-amd merged commit b1f073d into release/v2.4.x Sep 3, 2026
8 checks passed
@johnl-amd
johnl-amd deleted the EAI-8489-body-authz-cap-v24x branch September 3, 2026 12:22
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.

3 participants