fix: read --shelf-tags before the catalog swap

load_shelf_skus ran after write_catalog, so a missing path or a malformed list
escaped as a raw traceback over a catalog that had already been replaced. It is
now read inside the try, before anything is written, so both cases fail with the
tool's own message and the destination is untouched.

Adds BadShelfListFailsBeforeTheSwapTests, which asserts the clean message and
that the output path does not exist. Re-injecting the ordering fails both tests
with the raw FileNotFoundError. Suite 274 -> 276.
This commit is contained in:
tngo 2026-09-28 23:03:08 +09:00
parent 62183295f1
commit 13ee7426e2
2 changed files with 47 additions and 2 deletions

View file

@ -484,6 +484,10 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
print("eval-session check cannot cover image(s) with no capture_session_id: "
+ ", ".join(unlabelled), file=sys.stderr)
# Read the shelf list before anything is written: a bad path or a
# malformed list must fail here, with the tool's own message, rather
# than after write_catalog has already replaced the catalog.
shelf_skus = load_shelf_skus(args.shelf_tags)
engine = build_ocr_engine(args.ocr)
ocr_engine = engine if engine.available() else None
if ocr_engine is None:
@ -505,8 +509,7 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
# and vetoes it from the CSV alone, so it is a coverage gap, not a refusal.
text_only = sorted(set(names) - set(kept))
siblings = text_discriminated_siblings(kept, args.source, names)
small = below_pyramid_floor(kept, args.source)
verdict = live_ready_verdict(kept, names, load_shelf_skus(args.shelf_tags))
verdict = live_ready_verdict(kept, names, shelf_skus)
report = {
"source": args.source,
"output": args.output,