Skip to content

fix(node): keep the error chain when handlers return AcceptError - #2251

Merged
alpergundogdu merged 1 commit into
mainfrom
claude/accept-error-from-boxed
Sep 30, 2026
Merged

alpergundogdu merged 1 commit into
mainfrom
claude/accept-error-from-boxed

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Summary

  • The client, DHT and probe ProtocolHandler::accept impls converted their anyhow::Error with AcceptError::from_err(std::io::Error::other(e.to_string())), which keeps only the top-level message and drops every source() cause.
  • They now use AcceptError::from_boxed(e.into()). AcceptError::User is #[error(transparent)], so Display is unchanged and the full cause chain stays reachable through source().
  • The probe slash-signing comment now states the real reason that path logs at error level itself: iroh logs a failed handler at warn level with only the top-level message.

Test plan

  • cargo fmt -- --check: clean
  • cargo clippy --workspace --all-targets --all-features: no issues
  • cargo nextest run -p decdn-node --no-fail-fast: 1513/1513 passed (1 flaky retry in node_origin_pull)
  • The node_origin_pull a_probe_cache_hit_* tests are flaky here and fail the same way on unmodified origin/main (reproduced with 5 runs each), so the flake predates this change
  • Pre-commit hooks (fmt, clippy, doc, deny, tracing error fields): passed

🤖 Generated with Claude Code

The client, DHT and probe ProtocolHandler::accept impls wrapped the
anyhow error as AcceptError::from_err(io::Error::other(e.to_string())).
to_string() keeps only the top-level message, so every source() cause
was dropped before iroh saw the error.

AcceptError::from_boxed takes the anyhow error as a boxed dyn Error.
AcceptError::User is #[error(transparent)], so Display is unchanged and
the full cause chain stays reachable through source(). The probe signing
comment now states why that path logs at error level itself.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings September 30, 2026 14:15

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 review overview

🟢 Approval recommended

The change is a small, consistent, correctness-preserving refactor applied uniformly to all three handlers with no remaining occurrences of the old pattern and an accurate comment update.

Review effort: Balanced
Findings: None

What changed in this PR

This PR fixes error-context loss in the three ProtocolHandler::accept implementations of the decdn-node daemon. Previously each handler flattened its anyhow::Error into AcceptError::from_err(std::io::Error::other(e.to_string())), which kept only the top-level message and discarded the entire source() cause chain. The handlers now use AcceptError::from_boxed(e.into()); since AcceptError::User is #[error(transparent)], the Display output is unchanged while the full cause chain remains reachable via source().

I verified that serve() returns anyhow::Result<()> in each handler, that all three call sites were updated with no leftover instances of the old pattern, and that the anyhow::Error → Box<dyn Error + Send + Sync> conversion preserves the chain. The probe comment update accurately explains why that path logs at error level itself (iroh logs a failed handler only at warn level with the top-level message).

Changes:

  • Replace lossy AcceptError::from_err(io::Error::other(e.to_string())) with AcceptError::from_boxed(e.into()) in the client, DHT, and probe handlers to retain the full error cause chain.
  • Update the probe slash-signing comment to state the real reason it logs at error level.
File Description
crates/​node/​src/​handlers/​probe.rs Preserves error chain in accept; clarifies the slash-signing error-log rationale comment.
crates/​node/​src/​handlers/​dht.rs Preserves error chain in accept via from_boxed.
crates/​node/​src/​handlers/​client/​mod.rs Preserves error chain in accept via from_boxed.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-code-quality

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit 03f3c41 in the claude/accept-error-... branch remains at 87%, unchanged from commit 4fd9b70 in the main branch.

Show a line coverage summary of the most impacted files.
File main 4fd9b70 claude/accept-error-... 03f3c41 +/-
crates/node/src/runtime/mod.rs 54% 52% -2%
crates/node/src/dht/publish.rs 92% 92% 0%
crates/client/src/lib.rs 92% 92% 0%
crates/cli/src/...mmands/fetch.rs 71% 71% 0%
crates/cli/src/...nds/register.rs 29% 35% +6%
crates/cli/src/...doctor/ports.rs 64% 73% +9%
crates/node/src...reachability.rs 0% 81% +81%
crates/node/src...addr_publish.rs 0% 97% +97%
crates/node/src...t/dial_addrs.rs 0% 99% +99%
crates/common/src/net.rs 0% 100% +100%

@alpergundogdu
alpergundogdu merged commit ef4bb89 into main Sep 30, 2026
31 checks passed
@alpergundogdu
alpergundogdu deleted the claude/accept-error-from-boxed branch September 30, 2026 14:29
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.

2 participants