fix: service: keep RaftReply.error a decodable ApiError #8
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 · 242 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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.329
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #8"
general
weight: 0.35
lichuang
Finding
P2 —
RaftReply.errorhas two encodings, and the fallback loses the error.src/service/raft_service_impl.rs::error_replypostcard-encodes anApiErrorinto
RaftReply.error— except in the branch that runs when that encodingfails:
Every client decodes the field with
decode::<ApiError>(...)(
forward.rs::forward_request_to_leader,cluster.rs::join_via,network/connection.rs::forward). Handed plain text, they fail withso the original error, its kind, and its retryability are all lost — the exact
failure the unified
ApiErrorwire codec was introduced to fix.The branch is nearly unreachable (the payload is an enum of
Strings and anOption<u64>), but "nearly" is not a wire format: the invariant is that thisfield is always a postcard
ApiError.How to reproduce
The same holds for a redirect: a fallback-encoded
ForwardToLeaderreply losesits leader id, so the client can no longer forward.
The fix
The fallback now encodes an
ApiError::Internalwith the same codec, so thefield always carries the format its readers use; should that ever fail too, the
field stays empty (the client reports a decode error rather than acting on
garbage).
Tests added:
test_error_reply_is_a_decodable_api_errorandtest_error_reply_keeps_the_redirect_target(leader id survives the wire andstays forwardable).
cargo fmt --check,cargo clippy --all-features -- -Dandwarnings
cargo test --lib(84 tests) pass.