Repository navigation
fix(extract): validate currency_column cells and --currency for every importer - #2531
Merged
Merged
Conversation
… importer A currency_column cell that is not a commodity is now a row error naming the row, the column and the value, instead of a posting that fails to re-parse later; a lower- or mixed-case ISO code in a cell is upper-cased. --currency is checked once at the start of the run for every importer type, and an OFX/WASM entry's currency like a CSV entry's, through one shared check_currency. Closes #2516 Closes #2517 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
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 |
…ency one "currency_column X is V, which is not a valid commodity (commodities are upper-case, like `USD` or `EUR`)", matching #2498. Pins that the value is validated after upper-casing (full-width letters and an inner space stay refused) and that surrounding whitespace is trimmed first. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
This was referenced Oct 8, 2026
Member
Author
Review (adversarial pass)
Cross-PR integration (applies to #2524, #2526, #2527, #2531, #2532, #2533)All six PRs were merged onto
|
This was referenced Oct 8, 2026
…currencies # Conflicts: # CHANGELOG.md
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
…currencies # Conflicts: # CHANGELOG.md
…currencies # Conflicts: # CHANGELOG.md
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
#2516:
currency_columncells are validated. Each non-blank cell goes throughrustledger_parser::is_valid_currency, the lexer's own commodity rule.rustledger-importernow depends onrustledger-parser; there is no cycle, and it is a workspace crate already in the lock. A cell that is not a commodity is now a row error naming the row, the column and the value. The other rows still import:Before, the value went into the posting as is and failed much later as
canonical formatter failed to re-parse, naming nothing.Decision: a lower- or mixed-case cell (
usd,Eur) is upper-cased, not refused. Only the ASCII case changes, and the value is validated after that change: full-widthusd(not ASCII),U SDand€,US$,1USDare refused. Surrounding whitespace is trimmed first (usdimports asUSD). The message is worded exactly like #2498's configured-currency error. The reasoning:currency = "usd"is the user's own and fixed once at its source (that one stays refused, as fix(extract)!: take a CSV entry's missing currency from its open directive #2498 made it);usdcan only meanUSD, and upper-casing cannot produce a wrong commodity;This is documented at
CsvImporter::cell_currency, indocs/commands/extract.md(currency_column), and in the CHANGELOG.#2517:
--currencyis checked once, at the start of the run, for every importer type. The CSV path checked it, but OFX and WASM did not. It is checked even when a--ledgerprofile will outrank it, since an invalid flag is a typo either way. An OFX/WASM entry'scurrencyis now checked the same way, naming the entry. The check is one sharedcheck_currency(value, source), used byresolve_entry_currency(CSV) and the newminimal_currency(OFX/WASM), so both paths refuse the same values with the same message.How tested
a_currency_cell_that_is_not_a_commodity_is_a_row_error:€,US$and1USDare each a row error naming row, column and value, while the valid row imports. By index, the column is named by its number.a_lowercase_currency_cell_is_uppercased:usdandEurcome out asUSDandEUR.an_invalid_currency_is_refused_for_every_importer_type:usd,€and""passed as--currencyare refused with--currency is …on an OFX file and on a WASM-dispatched file (a WAT importer), and an OFX entry'scurrency = "usd"is refused naming the entry.cell_currencypassing cells through, both importer tests fail. With the start-of-run check and the entry check removed, the CLI test fails.cargo test -p rustledger-importer -p rustledger --all-features, workspace clippy (-D warnings) and rustdoc (-D warnings) are clean.Closes #2516
Closes #2517
🤖 Generated with Claude Code
https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr