← Back to Pull requests

fix(protocol): reject oversized declared responses #1624

Open
unknown opened this pull request with 397 lines diff across 4 files
View on GitHub
unknown unknown commented on Nov 27, 2026 12:10 UTC
Author

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 oversized Content-Length lets Praxis return a complete error instead of a truncated response.

How

  • trustworthy_content_length reads the upstream Content-Length before hop-by-hop stripping and response filters. It returns a length only when there is no Transfer-Encoding and every value is the same decimal number.

  • After response filters run, and only for a final response that still carries a body, response_body_limit_exceeded compares that length with the limit already enforced incrementally: a SizeLimit mode's own cap, otherwise the global max_response_bytes ceiling.

  • Pingora: response_filter sets response_size_limit_exceeded and returns a non-retryable HTTPStatus(502). error_while_proxy keeps it final, and fail_to_proxy writes the formatted error or the gRPC trailers-only reply.

  • Hyper: settle_success releases the upstream session without keepalive and answers with the same classified error as a local reply.

  • Retriable upstream statuses and response-filter rejections still take precedence. Passive health ignores the local rejection unless the upstream status was 5xx.
  • Changes

  • Return a formatted 502 before forwarding the upstream body on Pingora and Hyper.

  • Preserve incremental enforcement for unknown-length responses, retry rules, and upstream health accounting.

  • Add response-limit metrics and tracing, documentation, and HTTP/1.1, HTTP/2, gRPC, and boundary tests.
  • Validation

  • Product unit tests, Hyper unit tests, FIPS tests, FIPS lint, and Hyper lint passed.

  • Security, resilience, and schema suites passed on both backends.

  • Pingora and Hyper integration suites each had two failures because this host lacks a private IP address; the response-size tests passed.

  • make lint passed Clippy and formatting but could not finish because cargo-machete is 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-Length exceeds 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_large error 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 -->

    Diff: 397 lines (+297 / -100) across 4 files Reviewer: rikatz Review duration: 5321m
    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
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 43.2% (MEDIUM) · Higher = larger blast radius
    43.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 23% · Safe to merge
    23%