← Back to Pull requests

fix(divide): enforce requestMaxSize on chunked request bodies #8033

Merged
Sean-Walker0 merged 2 files (80 lines) on Oct 24, 2026 03:37 UTC
View on GitHub
Sean-Walker0 Sean-Walker0 commented on Oct 23, 2026 06:48 UTC
Author

Fixes #7816. Supersedes #7820 (approved, but it conflicted with master after #7857 moved the selection/forwarding into forwardSelected with canary routing — this is the same fix rebased onto that structure, as requested in the review follow-up).

Modifications

A positive divide rule requestMaxSize was only compared against the Content-Length header. Chunked or unknown-length requests report -1, so the comparison succeeded without examining a single body byte — oversized streaming bodies were forwarded.

For unknown-length requests the limit is enforced on the actual bytes: the request is decorated with a counting body that resets per subscription (Flux.defer) and aborts the stream with ResponseStatusException(PAYLOAD_TOO_LARGE) (which GlobalErrorHandler already honours) once the forwarded size exceeds the maximum. The known-length fast path is unchanged; the decorated exchange is threaded through the forwardSelected call so canary selection, attributes and circuit-breaker recording all operate on it.

Verifying this change

  • doExecuteRejectsChunkedBodyExceedingRequestMaxSize — 2-byte chunked body under a 1-byte limit; the downstream drains the body and the stream must abort with ResponseStatusException carrying PAYLOAD_TOO_LARGE. Red on the un-fixed code (verified by temporarily bypassing the decorator), green after.

  • ./mvnw -pl shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-divide -am test -B — full module 103/103 green (all canary/circuit-breaker suites from #7857 included), checkstyle clean.
  • Notes

  • Addresses every point from the #7820 review (413 status, per-subscription counter, javadoc, typed assertions) on the new master structure.

  • Orthogonality: no open PR modifies DividePlugin on top of current master (the #7857 refactor is already merged here).
  • Make sure that:

  • You have read the contribution guidelines.

  • You submit test cases (unit or integration tests) that back your changes.

  • Your local test passed ./mvnw clean install -Dmaven.javadoc.skip=true (module-scoped: shenyu-plugin-divide with -am, 103 tests + checkstyle green).
  • Diff: 80 lines (+75 / -5) across 2 files Reviewer: Aias00 Review duration: 1248m
    All Vouch review confidence checks passed
    Residual risk 0.04 = Change Risk (0.31) × (1 − Review Confidence (0.85)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.31 · 80 lines diff across 2 files
    0.31
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.89 · 1 substantive comment(s)
    0.89
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    85%
    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.263
    Real PR Conversation Timeline
    3 items
    Aias00 Aias00 approved these changes on Oct 23, 2026 14:21 UTC
    Approved Reviewer

    The streaming guard is the right shape: it only engages when requestMaxSize > 0 and Content-Length is absent, so known-length bodies keep the existing fast path and there is no double accounting with the header check above it.

    Two things to consider, neither blocking:

    1. forwarded is a mutable field on the anonymous decorator, reset inside Flux.defer. That is correct for the sequential (and retry) case, because each subscription restarts the count. A concurrent second subscription of getBody() on the same exchange would race on it, though. If that can happen through the retry strategy, an AtomicLong removes the doubt; otherwise a comment stating the single-subscription assumption is enough.

    2. The 413 is raised from inside the body Flux, so it surfaces from chain.execute(...) rather than from the plugin's return value. The test proves the error type reaches the subscriber, but please confirm it reaches the client as a 413 response body rather than a bare stream error — the header-based path above returns a normal WebFluxResultUtils result, so the two rejection paths would otherwise behave differently at the edge.

    Approving; the above can be follow-ups.

    yuluo-yx yuluo-yx commented on Oct 24, 2026 03:25 UTC
    Contributor

    /retest

    Reviewers
    Assignees
    Sean-Walker0 Sean-Walker0
    Labels
    risk: low confidence: 85.4% 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: 30.7% (LOW) · Higher = larger blast radius
    30.7%
    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: 85.4% · Lower = rushed or shallow review
    85.4%
    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: 4.5% · Safe to merge
    4.5%
    Repository