add_account duplicate-detection regex isn't anchored → false 409s and silent double-writes #48
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found in the high-effort code review of PR #46.
fava_client.py:1652:The pattern has no leading anchor, so it matches
open <name>anywhere in the chart file — including inside another account'sdescriptionmetadata or a comment — and its(?:\s|$)boundary misses an inline;comment.Empirically verified both failure directions:
The false-negative is the dangerous one: a duplicate
openmakesbean-checkreject the file, breaking every subsequent/api/sourcewrite.Suggested fix
Anchor to an actual Open directive and use an account-boundary negative-lookahead so a prefix can't match a longer sibling either:
(Or, better, replace text-grepping with a query against Fava's parsed accounts / libra's account DB — see the centralization issue.)
Fixed and shipped in v0.4.0 (PR #46, catalog updated).
0ea96cd— extracted the check into a pure_open_directive_exists()anchored to a real<date> open <name>directive with an account-boundary negative-lookahead.3adb3d3— hardened the date/whitespace to match Beancount's actual DATE token ((17|18|19|20)[0-9]{2}[-/][0-9]+[-/][0-9]+) and ignored inter-token whitespace, after a coherence pass over the Beancount source.Covered by 12 unit tests (both false directions + prefix/child non-matches + slash/single-digit/multi-space/tab date variants).