Pin each RowCutOff arm of the native ledger parser with a cut response (#718) - #1200
Merged
Merged
Conversation
Every failure of the native ledger row parsers propagated as text, so ledger_masters refused as ledger_export_invalid with no cause. The one call into the row parser now classes its failure with NativeCollectionError::from_row: what the row holds is RowUnusable; a quick-xml failure or a response that ends inside the row is MalformedResponse, which the row parsers' four end-of-input arms now mark with RowCutOff. A failure the row parser already typed (a foreign-currency opening, #675) keeps its own class. The empty LEDGER row and the record-count overflow are typed where they are raised. Two tests that matched row-error text now assert the variant. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#718) Three of the four end-of-input arms that return RowCutOff had no test, so reverting one to an untyped bail! would turn MalformedResponse into RowUnusable with every test green (#1184's review). A party-master response is now cut inside a scalar field (TAXTYPE), inside a flattened field (EMAIL) and between a GST registration entry's children, and each must be MalformedResponse; each uncut response reads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ints # Conflicts: # src-tauri/crates/bridge-tally-protocol/src/native_ledger_collection_tests.rs
Member
|
Independent review (local, Opus) of babd936 Verdict: clean (no P1/P2/P3). Test only; clippy not run by me, CI pending at this head. Reviewed clean at babd936. Mark it ready and I'll queue that same head.
|
Contributor
Author
akshit-khandelwal47
marked this pull request as ready for review
October 4, 2026 20:27
Contributor
Author
|
Ready for review at babd936 |
lamemustafa
enabled auto-merge
October 4, 2026 20:29
Member
|
Queued at babd936 (the reviewed head): it enters the merge queue as soon as this head's pull-request checks finish green. Please push nothing more here. If it leaves the queue, I'll say why here. |
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.
Part of #718
Summary
The test-only PR the maintainers agreed on #718, in place of slice 3, which was measured as unneeded there. It closes the optional P3 from #1184's review.
Measured, from that review: of the four end-of-input arms in
native_ledger_collection.rsthat returnRowCutOffsince #1184, only the LEDGER row's arm had a test (a_ledger_row_refused_is_typed_by_class, which cuts before<OPENINGBALANCE>). Reverting any of the other three to an untypedbail!turnedMalformedResponseintoRowUnusablewith every test green. These arms are reachable: unlike the legacy parsers (see #718), the native ledger parser has no whole-document pre-check.New test:
a_response_cut_inside_any_ledger_field_is_malformed(native_ledger_collection_tests.rs). It usesmaster_response_with_extrawith one party-master field, cuts the response inside that field, and assertsNativeCollectionError::MalformedResponse:<TAXTYPE>GSread_scalar_rejecting_nested_markup<EMAIL>accountsread_flattened_optional_text<LEDGSTREGDETAILS.LIST><APPLICABLEFROM>20250401</APPLICABLEFROM>, with the list still openread_gst_registration_entryEach uncut response reads, as a control.
The GST case is cut between the entry's children, not inside
APPLICABLEFROM's text. Cut inside the text, the end of input is met by the inner field reader, not the entry's own loop, and that arm's mutant survived. Moving the cut is what makes it reach the arm (see Mutants).Test
At
babd936c, the head: the code commit with master merged in after #1184.No production code changes, so the
bridgelib suite is not affected.P4
a_ledger_row_refused_is_typed_by_class's fixture helpers (master_response_with_extra) and the typed variant Name why a native ledger export was refused for one row (#718, slice 2) #1184 added. One new test function, no new helper.Net LOC
From
git diff --numstatagainst master4e1de421: +34 / −0 innative_ledger_collection_tests.rs. All test code. The file is not pinned, so there is no ack.Mutants
Each reverted one
RowCutOffarm to an untypedbail!in a saved copy ofnative_ledger_collection.rs, ran the protocol crate's lib tests with--no-fail-fast, and restored the copy. All four arms are now killed.parse_native_ledger_collection_row_with_master_fields)a_ledger_row_refused_is_typed_by_class(from #1184)read_gst_registration_entrya_response_cut_inside_any_ledger_field_is_malformed(with the cut insideAPPLICABLEFROM's text it survived, which is why the cut moved)read_scalar_rejecting_nested_markupread_flattened_optional_textNot measured
master_response, cut in memory.Needs a lab run: none
This adds a test only; no request, response handling or tool output changes.
Migration, security and rollback
Review checklist
review-checklist.md line 10: Errors are actionable without exposing sensitive values.
🤖 Generated with Claude Code