Skip to content

fix(group): fail the run when UMI assignment fails - #631

Merged
nh13 merged 1 commit into
mainfrom
nh/fix-group-assignment-error-fatal
Jul 23, 2026
Merged

nh13 merged 1 commit into
mainfrom
nh/fix-group-assignment-error-fatal

Conversation

@nh13

@nh13 nh13 commented Jul 22, 2026 •

Copy link
Copy Markdown
Member

The bug

Both assign_umi_groups_impl call sites in group.rs caught the error, logged a warning, and substituted an empty position group:

log::warn!("UMI assignment failed, returning empty group: {e}");
...
return Ok(ProcessedPositionGroup { templates: Vec::new(), ... });

fgumi group then exited 0 having written a header-only BAM with the entire input silently discarded. Downstream consensus calling sees only an empty file, and nothing in the exit status distinguishes that from a clean run over a small input.

The trigger is easy to hit. --strategy paired requires the RX tag to carry two --delimited segments, so pointing it at single-segment UMIs fails for every position group — the whole BAM vanishes. A missing RX tag or mixed UMI lengths reach the same path. In each case the reads cannot be grouped at all, which is a usage error worth surfacing, not a group worth skipping.

The fix

Propagate the error from both paths:

  • The streaming process_fn returns an InvalidData io::Error.
  • The single-threaded path adds context and returns.

The accepted-template rollback both sites performed goes away with them — nothing continues past the failure, so there is no tally left to over-report and no accepted_before_assignment to remember.

Tests

test_umi_assignment_failure_does_not_overcount_accepted asserted the warn-and-continue contract this PR replaces — it checked that the metrics agreed with an empty output BAM. It is rewritten as test_umi_assignment_failure_fails_the_run, keeping both #[case]s so the threaded (--allow-unmapped, via should_use_parallel) and single-threaded call sites each stay covered, since they swallowed the error independently.

Verified RED against the unfixed source — both cases fail with group must fail when UMI assignment fails, not emit an empty BAM: () — then green after the fix.

Full suite green: 5694 passed, plus ci-fmt and ci-lint.

Note on scope

This is a behaviour change: inputs that previously produced an empty BAM and exit 0 now fail loudly. That is the point, but it is worth a look if anyone is relying on the old behaviour to skip pathological groups. I could not find a case where a partial input failure is expected — the assigner errors are all "this input cannot be grouped with these settings" rather than "this particular group is odd".

Summary by CodeRabbit

  • Bug Fixes
    • fgumi group now stops with an error when UMI assignment fails instead of silently dropping affected reads.
    • Error messages provide details about the assignment failure, helping identify invalid UMI tags, input data, or strategy settings.
    • Paired-strategy RX UMI errors now clearly indicate when the expected two hyphen-delimited segments are missing.

@nh13
nh13 temporarily deployed to github-actions July 22, 2026 06:28 — with GitHub Actions Inactive
@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 73982632-adfe-403b-aaea-7118710ab964

📥 Commits

Reviewing files that changed from the base of the PR and between 72adf52 and 91ad310.

📒 Files selected for processing (1)
  • src/lib/commands/group.rs

Walkthrough

fgumi group now aborts when UMI assignment fails in either threaded or single-threaded execution. Integration coverage expects an error containing the paired-strategy segment condition instead of successful completion with an empty output group.

Changes

UMI assignment failure handling

Layer / File(s) Summary
Propagate assignment errors
src/lib/commands/group.rs
Threaded and single-threaded execution now return contextual InvalidData errors for UMI assignment failures instead of emitting empty groups or rolling back accepted-template metrics.
Validate error behavior
src/lib/commands/group.rs
Integration coverage expects execute(...) to fail and checks the formatted “2 segments delimited by '-'” error text for both execution paths.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested labels: fgumi runall

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main behavioral change: UMI assignment failures now abort fgumi group.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch nh/fix-group-assignment-error-fatal

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

@codecov

codecov Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.56%. Comparing base (72adf52) to head (91ad310).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #631      +/-   ##
==========================================
+ Coverage   93.53%   93.56%   +0.02%     
==========================================
  Files         175      175              
  Lines      106543   106523      -20     
==========================================
+ Hits        99655    99668      +13     
+ Misses       6888     6855      -33     

☔ 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 commented Jul 23, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Both `assign_umi_groups_impl` call sites caught the error, logged a
warning, and substituted an empty position group. `fgumi group` then
exited 0 having written a header-only BAM with the entire input silently
discarded, and downstream consensus calling saw only an empty file.

The trigger is easy to hit: `--strategy paired` needs the RX tag to carry
two `-`-delimited segments, so running it against single-segment UMIs
fails for every position group. A missing RX tag or mixed UMI lengths do
the same. In each case the reads cannot be grouped at all, which is a
usage error the run should surface rather than a group worth skipping. A
warning on stderr is not a sufficient signal for total data loss.

Propagate the error from both paths: the streaming `process_fn` returns
an `InvalidData` `io::Error`, and the single-threaded path adds context
and returns. The accepted-template rollback both sites performed is gone
with them — nothing continues past the failure to over-report.

`test_umi_assignment_failure_does_not_overcount_accepted` asserted the
warn-and-continue behaviour; it is rewritten as
`test_umi_assignment_failure_fails_the_run`, keeping its two cases so
both the threaded and single-threaded call sites stay covered.
@nh13
nh13 force-pushed the nh/fix-group-assignment-error-fatal branch from 4d1d6d9 to 91ad310 Compare July 23, 2026 17:30
@nh13
nh13 temporarily deployed to github-actions July 23, 2026 17:30 — with GitHub Actions Inactive
@nh13

nh13 commented Jul 23, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@nh13

nh13 commented Jul 23, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@nh13
nh13 merged commit c7c8358 into main Jul 23, 2026
14 checks passed
@nh13
nh13 deleted the nh/fix-group-assignment-error-fatal branch July 23, 2026 21:26
@nh13 nh13 mentioned this pull request Jul 23, 2026

This branch was previously deployed

1 inactive deployment
github-actions — 91ad3100 Deployed Jul 23, 2026 by nh13 via coverage #2964
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