Skip to content

fix(summary): a mistyped sample folder fails instead of overwriting summary.json with an empty one - #480

Open
geiresx wants to merge 4 commits into
GeiserX:mainfrom
geiresx:pgp/rv-summary-collect-missing-dir
Open

geiresx wants to merge 4 commits into
GeiserX:mainfrom
geiresx:pgp/rv-summary-collect-missing-dir

Conversation

@geiresx

@geiresx geiresx commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

og summary collect never checked --sample-dir. A mistyped folder name, a file, or a folder without read permission walked as an empty folder. The collect then wrote a summary.json with every section missing and exited 0. With --out pointing at the sample's real summary.json, one typo replaced a good summary with an empty one, and nothing failed.

Fix

Before it reads anything, og summary collect now checks that --sample-dir is a folder it can list. If not, it exits 1 with ERROR: <folder>: not a readable folder: <reason> and writes nothing. This covers every group (--only a|b|c and the whole summary), because all of them go through the one command line.

  • An empty folder that exists is still collected, with every section missing, as before.
  • A step folder inside the sample folder that cannot be read still counts as empty. Only the root is checked.
  • The error uses the tool's own exit 1 form (ERROR: ...), the same as a run status it cannot read or an --out it cannot write. The review suggested og summary collect: error: ..., which this tool uses only for exit 2 (a command line it cannot read).
  • No output file or format changes. The only new behaviour is exit 1 where it used to write an empty summary.

Decisions outside the package's file list, each needed because a test pinned the old behaviour:

  • rust/crates/og-summary/src/collect/tests.rs: the unit test of an unwritable --out used --sample-dir x, a folder that does not exist, only to reach the write error. It now points at a folder that exists, so it still tests the write error. One line.
  • tests/parity/golden/summary-collect/no-folder/: the parity case no-folder pinned the old behaviour against the Python oracle (exit 0, an empty summary). It gets goldens for the deliberate fix: exit 1, the error line, no stdout, no no-folder.json.
  • tests/parity/cases.tsv: the case report-render/no-folder rendered the summary that og summary collect wrote for a missing folder. That summary no longer exists, and the harness cannot express "both sides write nothing" for a named output, so the case goes. report-render/empty renders the same all-missing summary, from a folder that exists.
  • tests/test_render_report.py: the raw-data export check collected a folder before it made it. It now makes the folder first. One line.

Not changed here, on purpose: tests/test_archaic_report.py (line 432) and tests/test_viral_report.py (line 251) also collect a folder that does not exist and fail with this fix. Both files are deleted by the open Rust ports #488 and #489, whose Rust replacements call the collector library and are not affected. Editing them here would give those PRs a modify/delete conflict. So this PR lands with or after #488 and #489.

How it was checked

  • New test rust/crates/og-summary/tests/rv_summary_collect_missing_dir.rs: a missing folder (whole summary and each --only group), a file, and a mode 000 folder each exit 1 and leave an existing --out byte for byte. Without --out, a missing folder exits on the folder, not on the write. An existing empty folder still exits 0 and writes a summary with sections missing.
  • Red first: the new test against main's collect.rs fails 4 of 5 (left: 0, right: 1 for the missing folder, the file and the mode 000 folder, and no "not a readable folder" without --out). The fifth, the empty folder, is the positive control and passes on both.
  • With the fix: cargo test -p og-summary passes (120 unit tests and the 5 new ones), cargo fmt --check and cargo clippy -p og-summary --all-targets --all-features -D warnings are clean.
  • Parity: scripts/ci/oracle-diff.sh summary-collect agrees on all 284 items in 71 cases with the new goldens; with the oracle run, each of the 4 no-folder goldens is reported as a deliberate fix, not stale.
  • The 33 Python and shell tests that reach the collector, run locally with the fixed og: all pass except test_archaic_report.py and test_viral_report.py, as described above.
  • CI on the first head: parity reported the 4 no-folder goldens as deliberate fixes and only report-render/no-folder as different, which the third commit removes. The og-leg tests failed only on the three Python tests named above. https://github.com/GeiserX/OwnGenome/actions/runs/44130263675
  • CI on head 91947ae: every fast check was green except Guard rust, whose og-leg step failed only on test_archaic_report.py and test_viral_report.py. https://github.com/GeiserX/OwnGenome/actions/runs/44153602675
  • CI on the current head 7a7a172 (main merged in, because GitHub reported a conflict in CHANGELOG.md; both entries kept): Docs, Lint, Nextflow, Rust, Freshness, Personal data, Container Test and Release are green. In Guard, og, parity, fake-docker, coupled-versions and image-vars are green. rust fails only in its og-leg step, again only on test_archaic_report.py and test_viral_report.py (test_og_leg_probe.py is the planted control that must fail, and the round2 personal-data failure is that step's own control). Guard's unit-tests, images and helper-binaries jobs were cancelled once rust went red, so they still have to run on the head that lands. https://github.com/GeiserX/OwnGenome/actions/runs/44274394351

Bead: C17

A missing, mistyped or unreadable --sample-dir walked as an empty folder,
so the collect wrote a summary.json with every section missing and exited
0, over a good summary when --out named it. cli() now checks that the
sample folder is a folder it can list before it reads anything, and exits
1 with "ERROR: <dir>: not a readable folder: <reason>" and writes nothing.
Step folders below it that cannot be read still count as empty.

The parity case summary-collect/no-folder gets goldens for the deliberate
fix (the Python oracle wrote an empty summary and exited 0), and the unit
test of an unwritable --out points --sample-dir at a folder that exists.

Bead: C17
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 58 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 85652cb and 7a7a172.

Files ignored due to path filters: 1

  • tests/parity/cases.tsv is excluded by !**/*.tsv
Files selected for processing: 10

  • CHANGELOG.md
  • rust/crates/og-summary/src/collect.rs
  • rust/crates/og-summary/src/collect/scan.rs
  • rust/crates/og-summary/src/collect/tests.rs
  • rust/crates/og-summary/tests/rv_summary_collect_missing_dir.rs
  • tests/parity/golden/summary-collect/no-folder/exit
  • tests/parity/golden/summary-collect/no-folder/no-folder.json.absent
  • tests/parity/golden/summary-collect/no-folder/stderr
  • tests/parity/golden/summary-collect/no-folder/stdout
  • tests/test_render_report.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

og summary collect now refuses a sample folder it cannot list. The raw-data
export check of tests/test_render_report.py collected a folder it had not
made yet; it makes it first. The report-render parity case no-folder
rendered the summary of a missing folder, which og no longer writes, so it
goes: report-render/empty renders the same all-missing summary of a folder
that exists.

Bead: C17
geiresx pushed a commit to geiresx/OwnGenome that referenced this pull request Nov 18, 2026

This branch has not been deployed

No deployments
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.

2 participants