fix(protocol): reject oversized declared responses #1624
All Vouch review confidence checks passed
Residual risk 0.23 = Change Risk (0.43) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 397 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.358
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #1624"
general
weight: 0.35
rikatz
What
Reject upstream responses whose declared body length exceeds the configured response limit before forwarding their headers.
Why
Once Praxis sends
200 OK, it cannot replace that status when the response body crosses the limit. A trustworthy oversizedContent-Lengthlets Praxis return a complete error instead of a truncated response.How
trustworthy_content_lengthreads the upstreamContent-Lengthbefore hop-by-hop stripping and response filters. It returns a length only when there is noTransfer-Encodingand every value is the same decimal number.response_body_limit_exceededcompares that length with the limit already enforced incrementally: aSizeLimitmode's own cap, otherwise the globalmax_response_bytesceiling.response_filtersetsresponse_size_limit_exceededand returns a non-retryableHTTPStatus(502).error_while_proxykeeps it final, andfail_to_proxywrites the formatted error or the gRPC trailers-only reply.settle_successreleases the upstream session without keepalive and answers with the same classified error as a local reply.Changes
502before forwarding the upstream body on Pingora and Hyper.Validation
make lintpassed Clippy and formatting but could not finish becausecargo-macheteis not installed. The remaining lint checks passed separately.Related to #1620.
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
Bug Fixes
Responses whose validated
Content-Lengthexceeds the configured limit now receive a complete local error before delivery. Responses at the limit remain allowed.Unknown-length responses remain limited while streaming; an overflow may leave an already-started response incomplete.
Oversized non-5xx responses in hedged requests no longer trigger extra attempts or count against endpoint health. Upstream 5xx responses retain their failure handling.
Custom error formatters receive the
response_body_too_largeerror code.Access logs now reflect delivered gRPC statuses, including proxy-generated errors. Local responses no longer inherit stale upstream gRPC status.
Documentation
Clarified response-size limits for streaming, hedged, and gRPC responses.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->