Skip to content

fix(aggregator): reject unknown arguments in backfill-usage-snapshots (#6973) - #6974

Merged
dezren39 merged 1 commit into
mainfrom
creator-a/6973-backfill-unknown-args
Nov 7, 2026
Merged

dezren39 merged 1 commit into
mainfrom
creator-a/6973-backfill-unknown-args

Conversation

@dezren39

@dezren39 dezren39 commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Fixes #6973

What

backfill-usage-snapshots.ts probed argv with a single indexOf("--dir") (the #3330 value guard) and never examined any other token: a typo'd --dirr <dir>, an unknown flag, a positional, the joined --dir=<path> form, and a duplicate --dir were all silently ignored — the run seeded the rebuilt history into the default store and exited 0.

This replaces the probe with a strict parse (parseStoreDirArg), mirroring rejectUnknownArgs in append-usage-snapshots (#6961) / compact-usage-snapshots (#6967) and the collect-fleet-feed contract (#3352/#3509): the only accepted forms are no arguments or one separated --dir <storeDir>; anything else is a usage error (exit 2, naming the offending argument) raised at module top, before any input is read or any store is created. The #3330 trailing/flag-like value rejection and its exact message are preserved.

Verification (laptop, worktree on main 0290574)

  • New pinning suite test/backfill-usage-snapshots-argv-6973.test.ts: --bogus, --dirr <dir>, positional, --dir=<path>, duplicate --dir all exit 2 naming the argument, and no store directory (default or operator-named) is created. Fails pre-fix (verified by stashing the script change: 0 pass / 1 fail), passes post-fix.
  • Existing test/backfill-usage-snapshots-dir-3330.test.ts still green (3/3 across both files).
  • Probe against the fixed script: --dirr <intended> → exit 2 unknown argument '--dirr', no default store created; control --dir <custom> → exit 0 appending to <custom>.

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Summary by CodeRabbit

  • Bug Fixes
    • The usage-snapshot backfill command now rejects unsupported, duplicate, or incomplete directory arguments with an error before reading input files or writing to a snapshot store.
    • Directory selection must use the separated --dir <directory> format.

@dezren39
dezren39 requested a review from a team as a code owner November 7, 2026 23:12
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-07T23:14:21.091884Z 12ddbf2 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dezren39 dezren39 added kind/bug Something isn't working (prefixed form of the classic bug label) app/aggregator Package/app: aggregator (pm-stack in this repo) app/pm-stack pm-stack (Pad/Grist) in developing-today/code source/creator Filed by the new-issue-creator job labels Nov 7, 2026
@coderabbitai

coderabbitai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

The backfill script now rejects unknown, duplicate, and invalid arguments before reading input files or writing the snapshot store. A regression test checks five invalid argument forms and verifies that no store directories are created.

Changes: Backfill argument validation

Layer / File(s) Summary
Argument parser and regression coverage
pm-stack/aggregator/scripts/backfill-usage-snapshots.ts, pm-stack/aggregator/test/backfill-usage-snapshots-argv-6973.test.ts
The script accepts no arguments or one separated --dir <storeDir> argument. It exits with code 2 for invalid arguments before input reads or store writes. The regression test checks five invalid forms, argument-specific error output, and that no default or named store directory is created.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: Minimal · up to 12ddb

Argument validation is ready to merge after normal checks. Checking the complete joined argument in the regression test is an optional improvement.

- [ ] 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app/aggregator Package/app: aggregator (pm-stack in this repo) app/pm-stack pm-stack (Pad/Grist) in developing-today/code kind/bug Something isn't working (prefixed form of the classic bug label) source/creator Filed by the new-issue-creator job

Projects

None yet

1 participant