Skip to content

fix(bam-io): propagate errors writing the final BGZF EOF block - #1046

Merged
nh13 merged 1 commit into
mainfrom
nh/bgzf-finish-propagates-eof-error
Oct 8, 2026
Merged

nh13 merged 1 commit into
mainfrom
nh/bgzf-finish-propagates-eof-error

Conversation

@nh13

@nh13 nh13 commented Oct 7, 2026

Copy link
Copy Markdown
Member

Summary

BgzfWriterEnum::finish on the single-threaded path flushed the last data block and then dropped the noodles BGZF writer, leaving the EOF block to Drop, which discards the write error. A failure writing that final block (e.g. the disk filling at the very end) left an output without its EOF marker while the command exited 0.

finish now uses the consuming noodles Writer::finish, so the EOF write error is returned, and then flushes the underlying writer on both the single- and multi-threaded paths. The multi-threaded path already propagated the writer thread's EOF error; it gains only the final inner flush.

No change to output on success: exactly one EOF block is still written.

Audit

Other finish paths in fgumi-bam-io already propagate: IndexingBamWriter::finish (vendored multithreaded writer, ? on the join result) and the SAM-input BGZF framers (try_finish()?). No production caller relies on dropping a BgzfWriterEnum/RawBamWriter instead of calling finish.

Limitation

finish surfaces errors returned by write and flush, including the final EOF block. The underlying file is dropped rather than closed explicitly, so errors the OS reports only at close() (e.g. deferred write-back on a network filesystem) are still not checked; that is left for a separate change.

Tests

  • test_bgzf_writer_finish_propagates_eof_write_error: a sink that rejects the EOF-block write makes finish() return that error (1 and 2 threads); fails on main for the single-threaded path.
  • test_bgzf_writer_finish_propagates_inner_flush_error: a failing final flush of the underlying writer, after the EOF block is written, surfaces.
  • test_bgzf_writer_finish_writes_exactly_one_eof_block: success path ends with exactly one EOF block (guards against finishing and then double-finishing on drop).

BgzfWriterEnum::finish on the single-threaded path flushed and then
dropped the noodles BGZF writer, leaving the EOF block to Drop, which
discards the write error. A failure at the very end of the stream (e.g.
disk full) produced an output without its EOF marker while the command
exited 0.

Finish by value via noodles Writer::finish so the error propagates, and
flush the underlying writer on both paths. Errors reported only when the
file is closed are still not checked.

No change to output on success; failures now surface.
@nh13
nh13 deployed to github-actions October 7, 2026 20:39 — with GitHub Actions Active
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Note

Reviews paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository: fulcrumgenomics/fgumi/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Essentials
  • Run ID: 1a219f92-6a6a-4918-a548-a6fe44aa3450

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@nh13

nh13 commented Oct 7, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai pause

@coderabbitai

coderabbitai Bot commented Oct 7, 2026

Copy link
Copy Markdown
✅ Action performed

Reviews paused.

@codecov

codecov Bot commented Oct 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.45%. Comparing base (62b98c0) to head (b088817).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1046      +/-   ##
==========================================
- Coverage   96.47%   96.45%   -0.03%     
==========================================
  Files         299      299              
  Lines      152214   152264      +50     
==========================================
+ Hits       146854   146868      +14     
- Misses       5360     5396      +36     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nh13
nh13 added this pull request to the merge queue Oct 8, 2026
Merged via the queue into main with commit 94577dc Oct 8, 2026
21 checks passed
@nh13
nh13 deleted the nh/bgzf-finish-propagates-eof-error branch October 8, 2026 01:09
@nh13 nh13 mentioned this pull request Oct 8, 2026

This branch was successfully deployed

1 active deployment
github-actions — b0888179 Deployed Oct 7, 2026 by nh13 via coverage #4866
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.

1 participant