Repository navigation
fix(query): skip advisory-only diagnostics on stderr, as check does - #2534
Merged
Merged
Conversation
Closing an account that still holds a balance is E1004, which is advisory-only: beancount does not flag it, so bean-check and bean-query print nothing, and `rledger check` already skips it (#1446). #2238 turned validation on in `query` (for `#balances.discrepancy`) without that skip, so `rledger query` printed "E1004: Cannot close account ... with non-zero balance" on ledgers `rledger check` called clean. `query` now filters with the same `is_advisory_only_code` predicate as `check`. Other diagnostics on the same load are still printed. 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?
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
…agnostics # Conflicts: # CHANGELOG.md
`query` printed `ledger.errors` only. Option diagnostics (E7001 unknown option, E7002 invalid value, the rest of E7xxx) are kept on `options.warnings`, so a misspelled option was reported by `rledger check` and bean-query and went unreported here. They are now printed first, as bean-query does, ahead of the validation errors, through the same `--no-errors` switch. Neither kind of diagnostic changes query's exit status (bean-query also exits 0). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
Member
Author
Review passI checked every surface that validates and prints diagnostics (table in the PR body), JSON output, and exit status.
Review pass 2Looked at the new option-diagnostic printing. Nothing found.
|
…agnostics # Conflicts: # CHANGELOG.md
…agnostics # Conflicts: # CHANGELOG.md
…agnostics # Conflicts: # CHANGELOG.md
This was referenced Oct 9, 2026
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.
rledger queryprintedE1004: Cannot close account ... with non-zero balanceon ledgers thatrledger checkandbean-checkboth pass.E1004 is advisory-only. Beancount does not flag closing an account that still holds a balance, so
bean-queryprints nothing, andcheckhas skipped the code since #1446 (rledger lint closed-nonemptyreports it). #2238 turned validation on inqueryso that#balances.discrepancycould be computed, but it printed every diagnostic, including the advisory one.querynow filters withis_advisory_only_code, the same predicatecheckuses. Every other diagnostic is still printed.Repro:
bean-query(beanquery 0.2.0)rledger checkNo errors foundrledger querybeforeE1004: Cannot close account Expenses:Food with non-zero balancerledger queryafterTests:
crates/rustledger/tests/query_advisory_diagnostics_test.rscovers two cases: the advisory code is not printed, and a real E2001 on the same ledger still is. Both fail with the fix reverted.The other surfaces don't have this problem.
reportdoes not validate. The wasm/LSP paths deliberately show advisory codes as warnings.Review pass: every surface that validates and prints diagnostics
The loader validates by default (
LoadOptions::default().validate == true), so I checked every call site.rledger check(text and--format json)is_advisory_only_code)rledger query(text, csv, json: one stderr path)is_advisory_only_code), this PRrledger lint closed-nonemptyErrorCoderledger report *,price,extract(--ledger/--existingloads),doctorvalidate: false)ag-rledger queryrun_with_writer, same filterwarnings(see below)ErrorCode::severity()Severity::Warning. Hiding it there would take it from editors and Fava, which show warnings as warnings.is_advisory_only_codeis the rule for the text CLIs that mirrorbean-check/bean-query. It is now used at both places that print validation diagnostics as text.querydropped the option diagnostics (E7001 unknown option, E7002 invalid value, ...). They live onoptions.warnings, noterrors, andcheckand bean-query both print them.querynow prints them first, as bean-query does.query_prints_option_diagnosticsfails without the change.-f json,-f csvand text.query's exit code, advisory or not.queryexits 0 after printing an E1001 or an E7001, and so does bean-query 0.2.0 on the same ledger. Only the parse and booking refusals (query/report exit 0 and emit data from a file that failed to parse #1908) exit non-zero. Unchanged by this PR.ag-rledger querypasses its diagnostics to the process's stderr.ag-rledger reportroutes them into the envelope'swarnings, so an agent reading only the envelope sees a report's warnings but not a query's E2001. That is the same gap the report sink was introduced to close. It is a follow-up: it needs a diagnostics sink onquery::run_with_writer.🤖 Generated with Claude Code
https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr