Repository navigation
fix(validate): report an invalid account name in a custom directive's values - #2890
Merged
Merged
Conversation
… values Beancount checks every account token against the configured roots, so `custom "budget" AAssets:A "x" 10 USD TRUE` (or `A-ssets:A`, `Assets0:A`, `Foo:Bar`) is `Invalid account name` there; rledger loaded it clean. The account values of a `custom` directive now go through the same check as account-valued metadata: `push_invalid_accounts` (the canonical `validate_account_name` with the ledger's `account_types`), one E1005 per value, in the order written, before the directive's metadata as in bean-check. A `pad` checked its source account only after its target was open, so an invalid (or unopened) source behind an unopened target was hidden. Both are now checked, as bean-check reports both. A validator test replays the stray-character matrix's excluded (account-name) rows and asserts each outside `option` is a parse error or an E1005, so the matrix's exclusion is held up rather than assumed; it fails without this fix (19 custom rows). WASM CACHE_VERSION 79: its cached error lists change. The loader cache archives parsed directives, which did not move. Closes #2809 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 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 |
This was referenced Nov 7, 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.
What changed
An account value in a
customdirective is now checked as an account name, as beancount 3.2.3 checks every account token:custom "budget" AAssets:A "x" 10 USD TRUEInvalid account name: AAssets:AE1005A-ssets:A,Assets0:AInvalid account nameE1005custom "x" Assets:A Foo:Bar Bar:BazE1005, in ordercustom "x" Foo:Barpluskk: Bar:Bazoption "name_assets" "Actifs"+custom "x" Actifs:A Assets:BAssets:BonlyAssets:Bonlycustom "x" Assets:A,custom "x" "Foo:Bar"How it works:
customvalues:push_invalid_custom_accountssends acustomdirective's account values throughpush_invalid_accounts. That is now the one check for an account read from a value: the canonicalvalidate_account_namewith the ledger's configuredaccount_types, so root prefixes are never string-matched. Account-valued metadata (compat(parser): metadata shapes beancount rejects that rledger accepts (True/true, invalid account roots, indented lines under option/plugin/include, posting filename/lineno) #2813) goes through it too.pad: apadstopped at an unopened target, so an invalid or unopened source behind it went unreported. Both accounts are now checked, as bean-check reports both (Invalid account name/unknown accountfor each).Invalid account name, on the grounds that rledger reports them at load time.test_validate_reports_every_account_name_row_the_stray_char_matrix_excludesnow checks that claim: it replays every excluded row outsideoption(1,760 rows) and asserts each one is a parse error or anE1005.optionrows are invalid option names, which the loader reports.customcheck removed it fails on the 19customrows, and the 19 pad rows also failed before the pad fix.cases()copy is drift-guarded by the TSV's case count, like the parser's.CACHE_VERSION79, becauseLedger's cached error list changes. The loader cache archives parsed directives, which do not move, so it stays at 60 (LOADER_CACHE_VERSION_PIN60).Why
Issue #2809. This matches beancount; no deviation is introduced.
How to test
Verification
customshapes and 3 pad shapes. The errors match on all of them except two, both outside this PR:custom "x" Assets:agives 2 parse errors where bean-check gives 1. This is the known capitalized-word lexing follow-up.E1005is placed on the directive's line (known from compat(parser): metadata shapes beancount rejects that rledger accepts (True/true, invalid account roots, indented lines under option/plugin/include, posting filename/lineno) #2813).ParserEntryTypes.Pad,ParserComplete.NoEmptyLines(each in-tree and in the compat corpus), andbeancount-blog-exampleschapter-{2,3}_src_balance. Each gainsE1001 Pad source account ... was never opened, which bean-check reports asInvalid reference to unknown accountfor that source.STRICT_BASELINE=1corpus and CST baselines pass. Parser output is unchanged, so no baseline rows move.cargo test --workspace --all-features --no-fail-fastpasses, exceptrustledger::integration_test, which writes fixed-name files under the sharedTMPDIRand collided with another lane's run. It passes with a privateTMPDIR.-p rustledger-validate -p rustledger-wasm -p rustledger -p rustledger-lspwere rerun and pass.cargo clippy --all-features --all-targets -- -D warnings,RUSTDOCFLAGS=-Dwarnings cargo doc --workspace --no-depsandcargo fmt --checkpass.Closes #2809
🤖 Generated with Claude Code