Fail a non-UTF-8 input cleanly instead of crashing the expanded run - #27
Merged
Merged
Conversation
The cohort-scale guard read the records TSV outside the per-input error
handling and did not catch UnicodeDecodeError, so a binary input (macOS
AppleDouble ._P001.vcf sidecars on vcf-bench-1, v3.1.0) killed a whole
--sample-representation expanded run with a traceback.
- Probe the first 1 MiB of each records TSV for UTF-8 before the guard, for
every representation, and report failures as stage input-encoding
("not a UTF-8 text VCF"); the other inputs still convert.
- The guard's reader raises InputEncodingError instead of leaking the
decode error.
- Skip ._* AppleDouble sidecars during directory enumeration (wrapper and
vcf_as_tsv.sh), with a notice; documented in docs/cli-reference.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Merged
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.
Problem
On vcf-bench-1 with the v3.1.0 image, a directory input containing macOS AppleDouble sidecars (
._P001.vcfetc.) crashed--mode full --sample-representation expandedwith a traceback:cohort_scale_refusal→read_records_tsv_sample_countcaughtOSError/csv.Error/StopIterationbut notUnicodeDecodeError, and the guard is called outside any per-inputtry. Condensed never runs the guard, so it failed cleanly later.Fix
check_records_tsv_is_utf8decodes the first 1 MiB of each records TSV and raisesInputEncodingError. It runs before the guard for every representation, and the call site reports it throughfail_currentat stageinput-encoding:not a UTF-8 text VCF (byte 0xa3 does not decode as UTF-8; …). The other inputs still convert; the run exits 1 withfailed_inputs.csv.read_records_tsv_sample_countturnsUnicodeDecodeErrorintoInputEncodingErrorinstead of leaking it.list_vcfs_in_dirandsrc/vcf_as_tsv.shskip._*files;resolve_input_snapshotprints one notice naming them. Documented indocs/cli-reference.md.Tests
In
test/test_cohort_guard_unit.py:InputEncodingError, not a decode error; a UTF-8 character split at the probe boundary is not flagged.main()(Docker mocked): a directory withP001.vcf+._P001.vcf(expanded) skips the sidecar and converts P001 (exit 0); a directory withP001.vcf+ a binaryx.vcf(expanded and condensed) fails x atinput-encodingand converts P001 (exit 1).Against the old
vcf_rdfizer.pythe new tests reproduce the vcf-bench-1 traceback exactly. Full unit suite: 906 tests OK (25 skipped).Limits
🤖 Generated with Claude Code