You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Compat]: Highlight which transaction is erroring out #901
Confirmed, thanks. All three pieces of this are fixable and the infrastructure mostly already exists — the validation path just doesn't use it. Breakdown:
1. Line number missing
rustledger-loader/src/process.rs:735-753 in run_validation(): when converting ValidationError → LedgerError, the location is hardcoded to None:
The ValidationError already carries span and file_id. The same file has the span→line conversion a few lines above (file.line_col(spanned.span.start)). Just needs to be wired up:
ValidationError::to_string() produces [E3001] Transaction does not balance: residual -1 USD. Then check.rs wraps it as error[E3001]: {that whole string} → duplication.
Fix: change to #[error("{message}")]. The CLI layer always adds error[{code}]: itself.
3. Transaction echo missing
crates/rustledger/src/report.rs has two formatters:
Parse errors: use miette::GraphicalReportHandler + LabeledSpan to render source snippets with arrows/annotations (report.rs:65-100).
Validation errors: one-line formatter at report.rs:108-163. No snippet.
The miette infrastructure is already there — it just isn't called for validation errors. Wiring the validation formatter to use the same path would give us Python-parity output:
error[E3001]: Transaction does not balance: residual -1 USD
--> main.beancount:4:1
│
4 │ 2026-04-07 * "my expense"
5 │ Expenses:Expense 10 USD
6 │ Assets:Wallet -11 USD
│
Scope of all three fixes together is moderate — roughly a day of work — and none of it needs new crates or design. I'll put together a PR.
Activity
robcohen commentedon Apr 23, 2026
Confirmed, thanks. All three pieces of this are fixable and the infrastructure mostly already exists — the validation path just doesn't use it. Breakdown:
1. Line number missing
rustledger-loader/src/process.rs:735-753inrun_validation(): when convertingValidationError→LedgerError, the location is hardcoded toNone:The
ValidationErroralready carriesspanandfile_id. The same file has the span→line conversion a few lines above (file.line_col(spanned.span.start)). Just needs to be wired up:2.
[E3001]duplicated in the messagerustledger-validate/src/error.rs:184:ValidationError::to_string()produces[E3001] Transaction does not balance: residual -1 USD. Thencheck.rswraps it aserror[E3001]: {that whole string}→ duplication.Fix: change to
#[error("{message}")]. The CLI layer always addserror[{code}]:itself.3. Transaction echo missing
crates/rustledger/src/report.rshas two formatters:miette::GraphicalReportHandler+LabeledSpanto render source snippets with arrows/annotations (report.rs:65-100).report.rs:108-163. No snippet.The miette infrastructure is already there — it just isn't called for validation errors. Wiring the validation formatter to use the same path would give us Python-parity output:
Scope of all three fixes together is moderate — roughly a day of work — and none of it needs new crates or design. I'll put together a PR.
fix(check): render validation errors with source snippets
fix(check): render validation errors with source snippets
fix(check): render validation errors with source snippets
fix(check): render validation errors with source snippets
Merge pull request #906 from rustledger/fix/issue-901-validation-erro…