Skip to content

fix(parser): report an invalid calendar date in a metadata or custom value - #2851

Merged
robcohen merged 3 commits into
mainfrom
fix/invalid-meta-dates-reported
Nov 4, 2026
Merged

robcohen merged 3 commits into
mainfrom
fix/invalid-meta-dates-reported

Conversation

@robcohen

@robcohen robcohen commented Nov 3, 2026

Copy link
Copy Markdown
Member

What changed

A date in a value position that is not a real calendar date is reported, as beancount reports it, instead of loading as no value with no error.

bean-check 3.2.3 vs rledger

Input bean-check main this PR
kk: 2024-02-30 (directive, transaction, posting metadata) day is out of range for month no error, no value P0015 day 30 out of range for 2024-02
kk: 2024-13-01, kk: 2024-00-01 month must be in 1..12 no error P0015 month 13 out of range
kk: 2024-01-00, kk: 2024-02-0, kk: 2023-02-29 day is out of range for month no error P0015
kk: 0000-01-01, 0000-01-01 open ... year 0 is out of range accepted P0015 year 0 out of range
custom "x" 2024-02-30 day is out of range for month value dropped, no error P0015
pushmeta kk: 2024-02-30 ... popmeta kk: the error plus Attempting to pop absent metadata key pushed None, no error P0015 plus P0022 at popmeta
cost {1 USD, 2024-02-30} day is out of range for month undated lot, no error P0015
kk: 2024-02-29, {1 USD, 2024-02-29} ok ok ok

How to test

cargo test -p rustledger-parser --test invalid_value_dates (9 tests). With the source change reverted, 4 fail (metadata, custom, pushmeta, year 0); the other 5 pin behavior main already has or must keep (key with no value, a split date reported once, valid dates, valid and split cost dates).

The parser, loader, CLI, LSP and wasm suites pass with --all-features, including the stray-character matrix and both strict corpus baselines (STRICT_BASELINE=1, 731 files) with no row moved. Clippy -D warnings, rustdoc and fmt are clean.

Loader cache v55, WASM cache v70.

Closes #2811

🤖 Generated with Claude Code

…value

A date in a value position that is not a real calendar date
(`kk: 2024-02-30`, a custom or pushmeta value, a cost date) loaded as no
value, or an undated lot, with no error. It is now the same
InvalidDateValue (P0015) error a directive's own date gets, from one
shared check (`invalid_value_date`) run by the header, metadata-line and
posting-line checks, so the green and red paths agree. The directive is
kept and a metadata key gets no value, as for `kk: 1/0`. A pushmeta with
such a date pushes nothing, as in beancount. Year 0 is refused everywhere,
header dates included, as beancount refuses it.

Loader cache v55, WASM cache v70.

Closes #2811

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@robcohen
robcohen requested a review from a team as a code owner November 3, 2026 13:05
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

Shape rustledger beancount Speedup RSS (rledger / beancount)
simple 38.4ms ± 1.6ms 578.3ms ± 10.8ms 15.1x 34.7 MB / 51.1 MB
investment 59.2ms ± 1.2ms 2135.9ms ± 22.4ms 36.1x 44.7 MB / 59.0 MB
fifo 56.3ms ± 0.5ms 11818.8ms ± 122.1ms 209.9x 40.7 MB / 58.9 MB

vs base, measured in this run

Shape base this PR Change RSS base → PR
simple 38.1ms ± 0.5ms 38.4ms ± 1.6ms +0.9% ✅ within noise 34.9 MB → 34.7 MB (-0.6%)
investment 59.7ms ± 1.7ms 59.2ms ± 1.2ms -0.8% ✅ within noise 44.7 MB → 44.7 MB (+0.1%)
fifo 56.4ms ± 1.1ms 56.3ms ± 0.5ms -0.1% ✅ within noise 40.7 MB → 40.7 MB (-0.0%)

A difference counts only when it clears the combined spread of the two measurements, per shape (2σ: simple 0.7ms, investment 0.9ms, fifo 0.6ms), and is at least 5%.
10,000 transactions per shape · 20 runs, 3 warmup · hyperfine

What do these numbers mean?
  • simple — Two-posting transfers, one currency. The historical workload — keep as the floor, not as the benchmark.
  • investment — Cost specs, per-unit prices and lot reductions. Exercises booking and inventory, which simple leaves at 0.3%.
  • fifo — Bare {} reductions against a FIFO account — how FIFO sells are normally written. The other four shapes reach the ordered-selection path twice in 2k transactions between them, so it was effectively unprofiled until it turned out to be quadratic (plan_ordered scans every lot per reduction: FIFO ledgers are quadratic (8.8s at 20k transactions) #2083).
  • vs base: the PR and the base-branch commit it is built on, built and measured in the same job
  • RSS: peak resident set size, a single sample — reported without a verdict because there is no spread to test it against
  • A shape with no beancount column is one bean-check reports errors on; it is timed for rledger only

@codecov

codecov Bot commented Nov 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

✅ Compatibility Test Results

Metric Result
Check Compatibility 100%
BQL Compatibility 100% (raw 93%, 179 masked)
Full AST Match 100%
Total Files 826
What's tested
  • Check: Exit codes and error counts match bean-check
  • BQL: Query results match bean-query
    The headline is the EFFECTIVE rate, after pairs where beanquery
    itself is wrong are masked. raw is the same run with nothing
    masked. A widening gap means the registry grew, not that rledger
    changed.
  • Files: ~800 test files downloaded from 10+ beancount repositories

Full results available in workflow artifacts

robcohen and others added 2 commits November 3, 2026 23:52
The v55 doc entry had its blank `///` separator glued onto the text, so
rustdoc ran it into the next paragraph. The CHANGELOG said year 0 is
refused everywhere; dates built from FFI input still accept it (#2856).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@robcohen
robcohen enabled auto-merge (squash) November 4, 2026 13:03
@robcohen
robcohen merged commit afa906d into main Nov 4, 2026
65 of 66 checks passed
@robcohen
robcohen deleted the fix/invalid-meta-dates-reported branch November 4, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(parser): invalid calendar dates in metadata and custom values silently load as NULL

1 participant