Repository navigation
fix: name each underlying error once in booking, query, plugin and importer error chains - #2617
Merged
Merged
Conversation
…porter error chains Same bug as #2515: an error that interpolated its cause into its own message and also returned it from source() printed the cause twice in a {:#} chain. BookingError::Interpolation, QueryError::Parse, PythonError::Io and ::Wasm, ConversionError::BookedCostInvariantViolated and seven WasmImporterError variants keep their complete message and no longer chain the cause; From impls are written by hand (#[from] implies #[source]). anyhow causes print with {:#} so their own chain stays in the message. WasmImporterError's `source` fields are renamed `error` (thiserror treats a field named `source` as the source). Closes #2574 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
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 |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Member
Author
Review loop
Required checks are 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
This is the same bug as #2515, fixed for the loader in #2563. An error type put its cause in its own message and returned it from
source(), so any{:#}/ chain rendering printed the cause twice.rledger'srender_erroris one such renderer, as is anyhow's alternate format.What changed
The fix follows #2563: keep the complete message and drop the duplicate from the chain. That keeps every
to_string()consumer's text, which#[error(transparent)]would not.BookingError::Interpolation(book.rs:46)#[from]; hand-writtenFrom<InterpolationError>QueryError::Parse(error.rs:41)#[from]; hand-writtenFrom<ParseError>PythonError::Io,PythonError::Wasm(python/mod.rs:68,72)#[from]; hand-writtenFroms.Wasmnow prints{0:#}, so thewasmtime::Error's inner causes, which only the chain carried, stay in the message.ConversionError::BookedCostInvariantViolated(convert/mod.rs:45, same pattern, not in the issue)#[from]; hand-writtenFromWasmImporterError:Encode(wasm.rs:165) and every other variant with the same pattern (Io,DirEntry,Compile,Runtime,Decode,ExportSignatureMismatch)#[source]. Struct variants rename the fieldsource→error, because thiserror makes a field namedsourcethe source.ExportSignatureMismatchprints{error:#}, likeCompileandRuntimealready did.render_error(#2525) is unchanged and still escapes the whole chain, which is now just the message. The importer variants that quote module text still escape it in their own message.API break (CHANGELOG
### Breaking): code matchingWasmImporterError::{Io, DirEntry, Compile, ExportSignatureMismatch} { source, .. }must useerror. EveryFromimpl is kept, so?works as before.How tested
One test per site, each asserting that the
{:#}-style chain equals the plain message and that the inner text appears once:interpolation_error_names_its_cause_once_2574(booking)parse_error_names_its_cause_once_2574(query)io_and_wasm_errors_name_their_cause_once_2574(plugin; also checks thatWasmprintsOUTER: INNER)booked_cost_invariant_error_names_its_cause_once_2574(plugin)wasm_importer_errors_name_each_cause_once_2574(importer). It builds one of everyWasmImporterErrorvariant behind an exhaustive match, so a variant added later must be added to the test. It also checks that every message still carries its cause, and the whole chain for ananyhowcause.Fail without the fix: with
#[source]put back on each changed field (keeping the hand-writtenFroms), all 5 tests fail.Checks run:
cargo test --all-featuresfor rustledger-booking, -query, -plugin and -importer: 1862 passed, 0 failed.cargo test -p rustledger --all-features: 1014 passed, plus one failure,host_time_budget_applies_to_python_plugins. It hit its wall-clock deadline on a machine at load average ~70, and passed 7/7 on rerun. That path usesPythonError::Execution, which this PR does not touch.cargo clippy --workspace --all-features --all-targets -D warningsis clean, and so is the release-configuration clippy.RUSTDOCFLAGS=-D warnings cargo docis clean for each changed crate.Closes #2574
🤖 Generated with Claude Code
https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr