Skip to content

fix(cache): print the full cause chain in CacheError Display - #2276

Merged
thiras merged 4 commits into
mainfrom
fix/2269-cache-error-chain
Oct 5, 2026
Merged

thiras merged 4 commits into
mainfrom
fix/2269-cache-error-chain

Conversation

@yigitdot

@yigitdot yigitdot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • The fix(cache): print the full cause chain in CacheError::Store and Internal Display #2269 bug: a log line that printed a bare CacheError with error = %e showed only the top message and dropped the iroh-blobs / origin causes.
  • The rule: CacheError::Store, Internal, OriginError and OriginError::DecompressionFailed name only themselves in Display and return their cause from source(). Each cause appears exactly once in a chain render. (main also printed the outermost context twice under {:#}.) .chain() walkers see every cause under a CacheError.
  • New helper: CacheError::display_chain() / decdn_cache::ErrorChain renders store error: context: root cause on one line. Every log site and operator message that printed a bare CacheError uses it (list below).
  • Flattening removed: anyhow!("… {e}") / anyhow::Error::msg(format!("…{other}")) wrappers become .context(), so the typed chain survives (delivery.rs ×2, engine.rs ×2).
  • S3 body errors: PrefixedBodyError keeps s3://bucket/key: <original> in Display. Its source() continues from the original error's own source, so the original is not printed twice.

Why source() and not chain-in-Display

An earlier revision of this PR put the chain in Display and removed source(). That broke decdn_client::classify. It walks .chain() for a local-disk io::Error (StorageFull, ReadOnlyFilesystem, …), and that error sits below a CacheError::Store on the node's pull path (admit_store.rs → client driver → pull_leg.rs ends_the_assembly). With the walk stopped at the CacheError, a full disk classified as Fault::Source, and the node paid and blamed each holder in turn. No test caught it. The new regression test pins it.

Sites switched to display_chain() / ErrorChain / {:#}

  • cache engine.rs: gc snapshot, observe-partial, open store walk, admit coverage, evict tag drop, quarantine tag drop, outboard fetch, own-origin range open, record_origin_pull span error field.
  • cache origin_range.rs: fail message, window fetch log.
  • node admin.rs: cache_error_to_rpc (the decdn node evict / inspect message).
  • node handlers/client/dispatch.rs: serve_audit, own-origin range probe ({e:#} on a bare CacheError ignored the # flag), size probe, inspect.
  • node handlers/client/fill.rs: all 8 pull-through logs.
  • node handlers/client/delivery.rs: mid-delivery export fault log.
  • node handlers/client/window.rs: missing / held ranges, outboard seed.
  • node handlers/probe.rs: 4 sites.
  • node dht/publish.rs: 3 sites.
  • node runtime/mod.rs and runtime/eviction.rs: 3 sites.
  • node node_origin/backend_source.rs: fault message.
  • node node_origin/mod.rs: Unreachable and OurLocalFault verdict logs ({err:#}).
  • cache OriginPullError / anyhow origin faults ({:#}, which the transparent OriginPullError passes through): engine.rs origin-advance log (a decompression failure kept only "failed to decompress gzip response body"), enumerate, origin-probe HEAD and size-probe logs; retry.rs retry-exhausted and transient-retry logs.

Chain walkers that can reach a CacheError (audited)

  • client/fault.rs is_local_disk_fault: works again (the bug above).
  • pull_leg.rs is_internal_fault / is_bao_corruption: work. The CacheError itself is a chain link.
  • error.rs origin_error_kind: works (walks its own source).
  • pull_verdict, serve-side is_peer_attributable / ErrEnd / PaidProgress / frame metering: these use anyhow is/downcast_ref, which never follows source(), so they are unchanged. The new delivery.rs .context wrapping adds no marker.

Test plan

  • a_full_disk_under_a_store_fault_ends_the_assembly (node): a CacheError::Store wrapping iroh_blobs::api::Error::io(StorageFull, ..), both directly in anyhow and through RangedStoreError::Backend. classify gives Fatal(Command) (the verdict LocalPullFault gets) and the assembly ends. It failed on the previous head (Source).
  • error.rs: short Display, source() is the cause, display_chain renders exactly variant: ctx: root, {:#}/{:?} name each cause once (unique tokens, so backtraces can't collide), origin_error_kind finds DecompressionFailed through a context layer.
  • s3.rs: a prefixed body error renders the original once; a payload whose cause sits outside its Display keeps that cause on the chain (fails if source() drops it).
  • admin.rs: cache_error_rpc_message_carries_the_cause_chain pins the decdn node evict message to store error: <ctx>: <root>.
  • pull_through.rs, held_corruption.rs, delivery.rs assertions render through the chain helper.
  • cargo nextest run -p decdn-cache (495), -p decdn-node --lib (1171), -p decdn-client --lib (506)
  • cargo clippy --workspace --all-targets -- -D warnings, cargo fmt -- --check, cargo doc with -D warnings

Follow-ups (pre-existing, out of scope): #2286

Closes #2269

🤖 Generated with Claude Code

CacheError::Store, Internal, and OriginError render their anyhow cause
with the alternate format, so error = %e log sites keep the underlying
iroh-blobs / origin causes. #[source] stays, so source()/chain() walks
are unchanged.

Closes #2269

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 1, 2026 21:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-code-quality

github-code-quality Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust, Solidity

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit 4112865 in the fix/2269-cache-error... branch remains at 87%, unchanged from commit 9f46eaf in the main branch.

Show a line coverage summary of the most impacted files.
File main 9f46eaf fix/2269-cache-error... 4112865 +/-
crates/node/src...ndlers/probe.rs 87% 86% -1%
crates/cache/src/retry.rs 95% 94% -1%
crates/cache/src/engine.rs 94% 94% 0%
crates/node/src/dht/publish.rs 92% 92% 0%
crates/client/src/scheduler.rs 95% 95% 0%
crates/node/src...lient/window.rs 76% 76% 0%
crates/client/s...c/connection.rs 97% 97% 0%
crates/client/src/streamer.rs 91% 92% +1%
crates/node/src/admin.rs 92% 93% +1%
crates/cache/src/error.rs 73% 96% +23%

Solidity / code-coverage/forge

The overall line coverage in commit 4112865 in the fix/2269-cache-error... branch remains at 92%, unchanged from commit 9f243c9 in the main branch.


Updated October 02, 2026 03:25 UTC

yigitdot and others added 2 commits October 2, 2026 01:12
Store, Internal, and OriginError render the whole cause chain in Display,
so they no longer expose it through source() as well. A {:#} or {:?} on
an anyhow chain that wraps a CacheError (the own-origin pull leg logs
this way) printed every inner cause twice. OriginError's field and
DecompressionFailed's field become `cause`, because thiserror treats a
field named `source` as the error source. DecompressionFailed renders
its decoder error and drops source() for the same reason.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…h display_chain

Removing source() from CacheError's cause-carrying variants hid every
cause below a CacheError from .chain() walkers. The client's fault
classifier then missed a full local disk under a CacheError::Store, so
a node pull blamed and paid each holder in turn instead of ending.

Store, Internal, OriginError and OriginError::DecompressionFailed now
name only themselves in Display and return the cause from source(), so
chain walkers see it and chain formatters name each cause once. The new
CacheError::display_chain / ErrorChain render the whole chain on one
line; every log site and operator message that printed a bare
CacheError uses it. Flattened anyhow!("..{e}") wrappers become
.context() so the chain survives. PrefixedBodyError continues its
source() from the original error's own source instead of repeating it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The origin-advance log printed an OriginPullError with to_string(), so a
decompression failure lost the decoder reason now that
DecompressionFailed names only itself. It and the other origin-pull log
sites (enumerate, origin-probe HEAD, size probe, retry exhausted,
transient retry) render with {:#}, which OriginPullError's transparent
Display passes through to the anyhow chain.

The S3 nested-cause test uses a payload whose cause is outside its
Display, so it fails when PrefixedBodyError::source() drops the chain.
The admin RPC message gains a test pinning its cause chain, and the
ErrorChain and cache_error_to_rpc docs describe what they render.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

@yigitdot
yigitdot requested a review from alpergundogdu October 3, 2026 04:53
@thiras
thiras merged commit 66f3272 into main Oct 5, 2026
30 checks passed
@thiras
thiras deleted the fix/2269-cache-error-chain branch October 5, 2026 04:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(cache): print the full cause chain in CacheError::Store and Internal Display

4 participants