Skip to content

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

Closed

Description

@yigitdot

Problem

CacheError::Store and CacheError::Internal (crates/cache/src/error.rs) keep the cause as #[source] anyhow::Error, but their Display is #[error("store error: {0}")] / #[error("internal fault: {0}")]. Plain {0} on an anyhow::Error prints only the outermost message, so every log site that records the error with error = %err (the cache crate's idiom) drops the iroh-blobs causes underneath. {err:#} at the log site does not help: CacheError is a thiserror enum, and the alternate flag does not reach the inner {0}.

Same class of defect as #2251 (error chain lost via to_string()), on the cache side.

Fix

Use anyhow's alternate format inside the Display so the whole chain prints on one line:

#[error("store error: {0:#}")]
Store(#[source] anyhow::Error),

#[error("internal fault: {0:#}")]
Internal(#[source] anyhow::Error),

One-line change per variant; every existing %err WARN gets the chain with no call-site churn. Keep #[source] so programmatic source() / chain() walks still work.

Trade-off

A consumer that prints both the message and the source list (e.g. tracing-subscriber's record_error sources=[…], or code walking chain() and joining) would show the causes twice. A grep found no such consumer for CacheError today and no test asserting on the store error: / internal fault: text.

Acceptance

  • A test that builds CacheError::Store(anyhow::anyhow!("root").context("outer")) and asserts its to_string() contains both outer and root; same for Internal.
  • cargo nextest run -p decdn-cache, clippy --all-targets, and cargo doc -D warnings clean.

Found while reviewing #2261.

Activity

  1. added
    kind:bug
    rust
    prio:low
    area:node
    on Oct 1, 2026
  2. self-assigned this
    on Oct 1, 2026
  3. moved this from Backlog to In progress in deCDNon Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:nodekind:bugprio:lowrust

Type

No type

Fields

Priority

None yet

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions