fix: expose wrapped errors via source() in Method and StatusError variants#1409
Open
zancas wants to merge 1 commit into
Open
fix: expose wrapped errors via source() in Method and StatusError variants#1409zancas wants to merge 1 commit into
zancas wants to merge 1 commit into
Conversation
…iants Issue #1404 was caused in part by an error-enum variant that carried its cause in a plain field without `#[source]`, silently severing the `source()` chain that the serving surfaces downcast-walk to attribute node rejections. The fix for that issue healed the variant that bit (`RpcRequestError::UnexpectedErrorResponse`); this commit closes the remaining structural gaps the follow-up audit found (#1408). `RpcRequestError::Method` now marks its payload `#[source]`, keeping the typed method-specific rejection reachable from `source()` walks. thiserror infers the required trait bounds per generated impl, so the generic parameter needs no explicit `std::error::Error` bound and no call site changes. Because a `#[source]` payload is a real error with a real message, the variant's display switches from `Debug` to `Display` formatting; nothing in the tree matched on the old format. The three `StatusError` wrapper variants — in `MempoolError`, `NonFinalisedStateError`, and `FinalisedStateError` — likewise gain `#[source]`; their display strings are unchanged. Following the test-first order, four regression tests were written and confirmed red before the fix: one in zaino-fetch pinning that `Method` exposes its payload via `source()`, and one per wrapper enum in a new `status_error_wrappers` test module in zaino-state. Closes #1408. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1408. Stacked on #1405 — the base branch is
fix/1404-send-rejection-masking; retarget todevafter #1405 merges. Only the top commit (fix: expose wrapped errors via source() in Method and StatusError variants) belongs to this PR.Problem
#1404 was caused in part by an error-enum variant carrying its cause in a plain field without
#[source], silently severing thesource()chain that the serving surfaces downcast-walk to attribute node rejections. PR #1405 fixed the variant that bit (RpcRequestError::UnexpectedErrorResponse); the follow-up audit (#1408) found the same latent pattern in four more places:RpcRequestError::Method(MethodError)inpackages/zaino-fetch/src/jsonrpsee/connector.rs— a typed method-specific rejection (and anything it wraps) was unreachable fromsource()walks.StatusError(StatusError)wrapper variants inpackages/zaino-state/src/error.rs(MempoolError,NonFinalisedStateError,FinalisedStateError).Fix
All four variants now mark their payload
#[source], preserving the invariant #1405 documented: any variant that wraps another error must expose it viasource(), or downstream attribution silently degrades to a generic wrapper message.The change is smaller than the issue predicted. The issue anticipated bounding the generic (
MethodError: std::error::Error), but thiserror infers the required trait bounds per generated impl, so no signature changes were needed anywhere — the whole workspace compiles unchanged.One deliberate behavior change: because a
#[source]payload is a real error with a real message,Method's display switches fromDebugtoDisplayformatting (Method error: MissingInputs→Method error: Missing inputs). Nothing in the tree matches on the old format.Tests (written first, confirmed red, now green)
method_exposes_method_error_via_source(zaino-fetch) pins thatMethodexposes its payload viasource()with the typed method error downcastable.status_error_wrappersmodule (zaino-state), one per wrapper enum, each asserting the wrappedStatusErroris reachable and downcastable viasource().All four failed before the fix with
source()returningNoneat the severed link.Verified with
cargo check --workspace --all-targets,cargo clippy --workspace --all-targets(exit zero; only pre-existing live-test warnings),cargo fmt --all, andcargo nextest runon the production set (370/370 green).🤖 Generated with Claude Code