Repository navigation
feat(extract): choose between importer entries by the file's columns - #2527
Merged
Merged
Conversation
When several [[importers]] entries match a file by filename_pattern, read the file's header (with each entry's own delimiter and header setting, through the CSV importer's reader) and keep only the entries whose named columns are all present. One survivor is used; otherwise the existing "Multiple importers match" refusal stands, now listing per entry which configured columns the header lacks. Entries the header cannot judge (index or default columns only, headerless, OFX, preprocess) are never ruled out. A single filename match is unchanged. Closes #2295 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 |
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
1 of 2 tasks
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
Content-based selection between
[[importers]]entries, option D as decided on #2295.When several entries match a file by
filename_pattern,extractreads that file's header and keeps only the entries whose named columns are all present. If one survives, it is used. Otherwise the existingMultiple importers match file …refusal stands. Its first line is unchanged, and it now adds one line per candidate saying what the header showed:Rules
*_columnkey set to a header name, with CLI column flags applied first, as they will be for the entry that runs.skip_header = true), an OFX entry, one that runspreprocess(its columns describe the command's output, not this file), one whose config does not build, and any entry when the file cannot be read as text. So index-based, headerless, OFX and WASM cases still get the refusal.preprocess, the CSV branch) go through the oneresolve_config_entry_named, and all check the source file. So the entry that preprocesses is still, by construction, the entry that extracts.Canonical functions, not copies
CsvImporter::header(content, &CsvConfig)reads the header with the same reader extraction uses (its delimiter andhas_header). The extraction path now calls the same helper.skip_rowsskips data rows after the header in this importer, so it does not move the header, and the header check behaves the same way.ImporterEntry::named_columns()reads names off the configbuild_config_from_entrybuilds, so a name and an index are told apart exactly as extraction tells them apart ("3"is an index in both).Why
petemounce's Starling GBP and EUR exports share a filename (
StarlingStatement_<from>_<to>.csv) and differ only inAmount (GBP)vsAmount (EUR). Two entries naming those columns can now be told apart without--importeror per-currency directories. This matches the reply drafted for the issue.How tested
New tests in
extract_cmduse petemounce's exact header shapes:the_header_picks_between_entries_matching_one_filename: the GBP header picksstarling-gbp, and the EUR header picksstarling-eur.a_header_selected_entry_imports_in_its_currency: end to end throughrun_with_writer, the rows come out in EUR and GBP respectively.no_entry_fitting_the_header_lists_missing_columns_per_entry: a USD header gets the refusal, with each entry's missing column.several_entries_fitting_the_header_are_still_refused.entries_the_header_cannot_judge_are_kept: index-only, headerless, OFX andpreprocessentries each keep the refusal and say why.a_single_filename_match_is_not_checked_against_the_header.named_columns_lists_only_columns_named_by_headerandheader_reads_the_row_extraction_reads.Shown to fail without the fix: with header filtering disabled, 5 of the 6 CLI tests fail. The single-match test passes either way by design. Existing tests, including
test_run_auto_select_errors_on_multiple_importers, pass unchanged.cargo test -p rustledger-importer -p rustledger --all-features, workspace clippy (-D warnings) and rustdoc (-D warnings) are clean.Closes #2295
🤖 Generated with Claude Code
https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr