← Back to Pull requests

Keep the server's ErrorResponse on ReplicationError #163

Closed
unknown closed this pull request without merging on Nov 18, 2026 09:42 UTC
View on GitHub
unknown unknown commented on Nov 14, 2026 12:46 UTC
Author

Summary

Every server ErrorResponse goes through from_sqlstate, which uses the SQLSTATE once to choose the variant and then folds it into the message text, so the fields parse_error_fields already parsed (severity, code, message, detail, hint, routine) are thrown away.

A consumer that needs a code outside the few that from_sqlstate promotes can only recover it by parsing [42883] out of the string.

The five variants a server error can land in (Protocol, TransientConnection, PermanentConnection, Authentication and ReplicationSlot) now carry the parsed response as a second field, read through ReplicationError::sqlstate() and ReplicationError::server_error(). Their message becomes a Box<str>, so ReplicationError, and with it every Result the parser returns, stays 32 bytes. The variant choice and the Display text are unchanged, so retry classification behaves as before.

The code is a sqlstate::SqlState from the sqlstate crate that Diesel publishes. It is no_std with no dependencies, so it also fits the parser-only build, and pg_walstream re-exports it. I am one of the maintainers there, so if changes need to be made I can do them reasonably quickly.

Most of the diffs in this PR consist of trivial replacements and cargo locks.

Type of change

  • Bug fix

  • New feature

  • Performance improvement

  • Refactor / internal cleanup

  • Documentation

  • CI / build
  • Checklist

  • make before-git-push passes locally (check, build, format, audit, test, doc-check)

  • Tests added/updated for the change (coverage stays ≥ 90%)

  • Both backends build (--features rustls-tls if connection/streaming code changed)

  • Docs / README updated if public API changed
  • Performance notes

    The messages are Box<str> to keep ReplicationError at 32 bytes. A String message next to the new field makes it 40 bytes, and CodSpeed measured that as a slowdown on zero_copy_path. With Box<str> it reports no change on all 50 benchmarks.

    Diff: 255 lines (+191 / -64) across 3 files Reviewer: LucaCappelletti94 Review duration: 5576m
    All Vouch review confidence checks passed
    Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 255 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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.332
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #163"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 39.1% (MEDIUM) · Higher = larger blast radius
    39.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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 15.4% · Safe to merge
    15.4%