Repository navigation
fix(loader): name the OS error once in a load error chain - #2563
Merged
Merged
Conversation
LoadError::Io interpolated its io::Error into its message and also exposed
it as source(), and ProcessError::Load did the same with the whole
LoadError, so a chain printer ({e:#}) repeated the OS error two or three
times. LoadError::Io keeps a complete message (every to_string consumer
relies on it) and its field is renamed `error` so it is no longer the
source; ProcessError::Load is transparent.
Closes #2515
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
…epeat # Conflicts: # CHANGELOG.md
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Contributor
📊 Benchmark Results
vs base, measured in this run
A difference counts only when it clears the combined spread of the two measurements, per shape (2σ: What do these numbers mean?
|
Contributor
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
Member
Author
Review loop
Converged after round 1. Required checks green on |
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.
What was wrong
A load failure printed through an error chain repeated the OS error:
and three times under
rledger extract --existingas reported. Two layers each put their source in their own message and returned it fromsource():LoadError::Io—#[error("failed to read file {path}: {source}")]with a field namedsource(which thiserror treats as the source).ProcessError::Load—#[error("loading failed: {0}")]with#[from](also the source).What changed
LoadError::Iokeeps its complete message, OS error included, and the field is renamedsource→error, so theio::Erroris no longer the variant'ssource(). Of the two ways to satisfy "source in the message or in the chain, never both", this one keeps every consumer that shows aLoadErrorwithto_string()intact: the loader's ownLOADdiagnostics (process.rs), the wasm error list,doctor. Dropping the OS error from the message instead would have silently lost it there.ProcessError::Loadis#[error(transparent)]: message and chain are theLoadError's.LoadErrorvariant carries no source (checked; the test below enumerates them exhaustively).check.rs(JSON/plainE0001rendering) and the wasm host FS only needed the field rename. The top-levelrender_errorfrom fix(plugin): run Python plugins via __plugins__ under the host time budget #2525 is unchanged and still escapes the (now shorter) chain.API break (CHANGELOG
### Breaking): code matchingLoadError::Io { source, .. }matcheserror.How tested
load_errors_name_each_cause_once(loader unit test): for one of everyLoadErrorvariant, alone and wrapped inProcessError::Load, the{:#}-style chain equals the plain message, and theIomessage still names the OS error.test_load_failure_names_the_os_error_once(CLI):rledger doctor stats|missing-open|display-contexton a missing file prints the OS error exactly once.#[source]restored on the field andProcessError::Loadback to"loading failed: {0}", both tests fail (chain…OS-ERROR-TEXT: OS-ERROR-TEXT;doctor statscount 2).cargo test -p rustledger-loader -p rustledger -p rustledger-wasm --all-features, clippy--workspace --all-features --all-targets -D warnings,cargo doc -D warnings -p rustledger-loader.Possible follow-ups (other crates, same pattern of
{0}+#[from]):rustledger-bookingbook.rs:46,rustledger-queryerror.rs:41,rustledger-pluginpython/mod.rs:68,72,rustledger-importerwasm.rs:165.Closes #2515
🤖 Generated with Claude Code
https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr