← Back to Pull requests

test(marshal): fix flaky TestMarshalProtoJSON #169

Open
arreyder opened this pull request with 43 lines diff across 1 files
View on GitHub
arreyder arreyder commented on Oct 15, 2026 17:13 UTC
Author

TestMarshalProtoJSON fails intermittently on main (3 of 40 runs locally). When the input contains NUL bytes, cleanJSON decodes into a map[string]interface{} and re-encodes with jsoniter's default config, which doesn't sort keys. The test compared raw strings, so key order decided pass or fail.

Output key order doesn't matter in production (the values land in JSONB), so this fixes only the test: it decodes the result with protojson.Unmarshal and checks it with proto.Equal against the expected Struct. This also drops a duplicate pre-loop call and error messages that said the opposite of what they checked.

Verification

  • 500 of 500 runs pass (-count=500). Before the fix, 3 of 40 runs failed.

  • Sabotage: making sanitizeJSON stop stripping \u0000 fails the With null bytes subtest.

  • go test ./pgdb/v1/ and golangci-lint are clean.
  • 🤖 Generated with Claude Code

    Diff: 43 lines (+17 / -26) across 1 files Reviewer: None requested Review duration: 74259m
    All Vouch review confidence checks passed
    Residual risk 0.29 = Change Risk (0.50) × (1 − Review Confidence (0.42)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 43 lines diff across 1 files
    0.50
    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: 10%
    42%
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.226
    No Reviewer Assigned no_reviewer_assigned
    0.120
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #169"
    general weight: 0.35
    Reviewers
    None requested
    Assignees
    arreyder arreyder
    Labels
    risk: low confidence: 42.2% 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: 49.6% (MEDIUM) · Higher = larger blast radius
    49.6%
    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: 42.2% · Lower = rushed or shallow review
    42.2%
    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: 28.7% · Safe to merge
    28.7%