mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-10-20 05:56:56 +00:00
feat(config): add maxRequestBytes for the unified body cap
The unified chat and embeddings routes reject bodies above 4 MiB. Long agent sessions exceed this limit and receive a 413. Add Config.maxRequestBytes. Zero or a negative value keeps the 4 MiB default. A positive value raises the cap, clamped to 64 MiB. An adversarial body decodes to about 12x live heap. An operator who raises the cap must also set maxInFlightBodyRequests and the pod memory limit.
This commit is contained in:
+5
-1
@@ -74,6 +74,10 @@ const maxRequestBytes = 10 << 20
|
||||
// package ships.
|
||||
const maxUnifiedRequestBytes = 4 << 20
|
||||
|
||||
// maxExplicitUnifiedRequestBytes is the ceiling for Config.MaxRequestBytes,
|
||||
// so an explicit value cannot disable the bound.
|
||||
const maxExplicitUnifiedRequestBytes = 64 << 20
|
||||
|
||||
// gatewayAliasKey is the request map's internal-convention key carrying
|
||||
// the client-requested model id through to an adapter (ruling a, ALIAS
|
||||
// ECHO), distinct from "model" itself, which runUnified rewrites to the
|
||||
@@ -1069,7 +1073,7 @@ func (g *Gateway) readAndDecodeUnifiedBody(sw *statusTrackingWriter, r *http.Req
|
||||
return nil, nil, false
|
||||
}
|
||||
|
||||
body, oversize, err := readCapped(r.Body, maxUnifiedRequestBytes)
|
||||
body, oversize, err := readCapped(r.Body, g.unifiedRequestBytes)
|
||||
if err != nil {
|
||||
envelope(sw, http.StatusBadRequest, "invalid_request_error", "cannot read request body")
|
||||
return nil, nil, false
|
||||
|
||||
Reference in New Issue
Block a user