Skip to content

aggregator(produce-charge-candidates): unknown/misspelled/joined/duplicate arguments silently ignored — a typo'd --strat writes candidates for the wrong (default) period, a typo'd --skip-gmal runs the Gmail read anyway, all exit 0 #7301

Closed

Description

@dezren39

aggregator(produce-charge-candidates): unknown/misspelled/joined/duplicate arguments silently ignored — a typo'd --strat writes candidates for the wrong (default) period, a typo'd --skip-gmal runs the Gmail read anyway, all exit 0

Summary

pm-stack/aggregator/scripts/produce-charge-candidates.ts probes argv token-by-token only: argValue() does process.argv.indexOf(flag) (:112) and the Gmail opt-out is process.argv.includes("--skip-gmail") (:454). There is no unknown-argument rejection. The value half of this script's argument contract was hardened by #3333 (trailing/flag-like values, real-calendar dates, end >= start), but the unknown-token half was left — the same residual pattern fixed in the sibling scripts by #6961 (append-usage-snapshots), #6967 (compact-usage-snapshots), #6973 (backfill-usage-snapshots), #7097 (generate-digest), #7254 (collect-github-billing), and #7289 (post-alert). Part of the #3352 "unknown means stop" family.

Evidence (verified this run, main 688f44dbe0)

Laptop probe ~/git/fleet/probe-charge-unknown-args — the real script copied verbatim (md5 5763f90fa815740affa56238690bad88, identical to the laptop primary at 688f44dbe0; src/charges-match.ts md5-matched too), Bun, PLAID_CLI/GMAIL_CLI pointed at stubs that log their arguments, CHARGE_CANDIDATES_PATH pointed at a probe-local file:

Case Result
control: --skip-gmail --start 2026-09-01 --end 2026-09-30 --out <probe>/control.json exit 0; period 2026-09-01..2026-09-30; Plaid queried --start-date 2026-09-01 --end-date 2026-09-30; Gmail not called
typo'd flag: --strat 2026-09-01 --end 2026-12-31 --skip-gmail exit 0; period silently became 2026-11-01..2026-12-31 (the default current-month start); Plaid queried for the wrong period; candidates file written for it
joined flag: --start=2026-09-01 --end 2026-12-31 --skip-gmail exit 0; same wrong default period 2026-11-01..2026-12-31 written
typo'd opt-out: --skip-gmal --start 2026-09-01 --end 2026-09-30 exit 0; the Gmail read the operator asked to skip ran anyway (two gmail +triage calls logged)
duplicate flag: --start 2026-09-01 --start 2026-10-01 --end 2026-12-31 --skip-gmail exit 0; first --start silently wins (period 2026-09-01..2026-12-31), no complaint
unknown token: --bogus with otherwise valid flags exit 0; silently ignored

Why it matters

This producer writes charges-candidates.json, the live input the fleet-feed collector consumes for charge matching. The dangerous direction is silent: an operator who typos the period produces — and overwrites the candidates file with — a batch for the default period while believing they produced the requested one, and an operator who typos the Gmail opt-out triggers the connector reads they explicitly asked to skip. Nothing in the output line looks wrong; it prints the substituted period as if it were requested. The sibling scripts were all fixed for exactly this class because a misspelled flag must be a usage error, never a silent change of behavior.

Acceptance criteria

  • Any argv token that is not a known flag (--start, --end, --out, --skip-gmail) or a known flag's value is a usage error: exit 2 with a message naming the token, before any connector call or file write (mirrors rejectUnknownArgs() in post-alert.ts / generate-digest.ts).
  • Joined forms (--start=2026-09-01) and duplicated value flags are likewise usage errors, not silently ignored / first-wins.
  • Known flags keep working unchanged in both modes: live mode explicit periods and staged mode (CHARGE_INPUTS_DIR set), where --start/--end remain accepted-but-ignored per the staged-manifest contract pinned by the existing test "staged manifest period remains authoritative over CLI period flags".
  • Regression tests in test/produce-charge-candidates.test.ts (the existing liveHarness/expectCliUsageError harness) cover: unknown token, typo'd --strat, joined --start=, duplicate --start, and typo'd --skip-gmal — each asserting exit 2, no Plaid/Gmail stub calls, and no candidates file written or overwritten; the new tests fail on the pre-fix script.
  • The existing produce-charge-candidates suite stays green.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    source/creatorFiled by the new-issue-creator job
    on Nov 8, 2026
  2. developing-today commented on Nov 8, 2026

    @developing-today
    Contributor
  3. added
    priority/normalOrdinary priority (the default)
    app/aggregatorPackage/app: aggregator (pm-stack in this repo)
    on Nov 8, 2026
  4. dezren39 commented on Nov 8, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

  5. dezren39 commented on Nov 8, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

  6. added
    work/self-assignedAn agent grabbed this item directly, outside the queue
    and removed on Nov 8, 2026
  7. dezren39 commented on Nov 8, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done (duplicate — fixed via the parallel lane's issue)

  8. added and removed
    work/self-assignedAn agent grabbed this item directly, outside the queue
    on Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/aggregatorPackage/app: aggregator (pm-stack in this repo)kind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus/duplicateAlready tracked elsewherestatus:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions