← Back to Pull requests

[ISSUE #8686] Decode mock JSON request bodies as UTF-8. #8687

Open
wozhenbang2004 opened this pull request with 56 lines diff across 3 files
View on GitHub
wozhenbang2004 wozhenbang2004 commented on Nov 27, 2026 15:54 UTC
Author

Fixes #8686.

Mock expressions that read #req.json decode the request body with the JVM default charset. A UTF-8 request such as {"city":"北京"} returns garbled text when the gateway runs with a different default. Decode JSON request bytes as UTF-8 before parsing, as specified by RFC 8259. This does not change expression syntax or form handling. Non-UTF-8 JSON no longer falls back to the JVM charset.

IssueSpec

IssueSpec-Mode: lightweight
IssueSpec-Reason: Correct decoding of the existing Mock JSON body format without changing the plugin API or configuration. Classification is pending maintainer confirmation.
IssueSpec-Validation: With a non-UTF-8 JVM default, the base revision fails only the new expression test. All 85 Mock tests pass with the patch under US-ASCII, ISO-8859-1 and UTF-8 defaults on JDK 21. A loopback HTTP POST through the Mock plugin reproduces the garbled JSON on the base revision and returns the original text with the patch. Checkstyle passed on the two changed files.

  • You have read the contribution guidelines.

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

  • New production code follows the code quality rules Q1-Q9 in AGENTS.md.

  • Your local test passed ./mvnw clean install -Dmaven.javadoc.skip=true.
  • Diff: 56 lines (+55 / -1) across 3 files Reviewer: None requested Review duration: 9001m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.42) × (1 − Review Confidence (0.66)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 56 lines diff across 3 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.56 · 1 substantive comment(s)
    0.56
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 10%
    65%
    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.242
    No Reviewer Assigned no_reviewer_assigned
    0.120
    Real PR Conversation Timeline
    2 items
    wozhenbang2004 wozhenbang2004 commented on Nov 30, 2026 04:24 UTC
    Author

    Thanks for catching this. I added a report name suffix for the US-ASCII run in c7bc79f and verified that Surefire now keeps both XML reports.

    Reviewers
    None requested
    Assignees
    wozhenbang2004 wozhenbang2004
    Labels
    risk: low confidence: 65.8% 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: 42.1% (MEDIUM) · Higher = larger blast radius
    42.1%
    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: 65.8% · Lower = rushed or shallow review
    65.8%
    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: 14.4% · Safe to merge
    14.4%
    Repository