Skip to content

aggregator(generate-digest): unknown/misspelled flags silently ignored — typo --knd archives a daily digest, typo --no-delivre delivers anyway #7097

Closed

Description

@dezren39

aggregator(generate-digest): unknown/misspelled flags are silently ignored — a typo'd --knd weekly archives a daily digest, and a typo'd --no-delivre delivers anyway

Evidence (verified this run, laptop primary @ bfa5cae; file md5-identical to origin/main 602b5d9)

pm-stack/aggregator/scripts/generate-digest.ts probes argv token-by-token and never rejects a token it does not recognize:

  • arg() (:32-33) finds --kind via process.argv.indexOf(...) only; any other --flag token is never examined.
  • Delivery suppression is process.argv.includes("--no-deliver") (:77) and strict mode is process.argv.includes("--strict-deliver") (:120) — a misspelling simply makes the check false.
  • The USAGE string (:23) documents exactly three flags (--kind, --no-deliver, --strict-deliver), but nothing enforces that set.

Probe (laptop ~/git/fleet/probe-digest-unknown-args/probe.test.ts, subprocess runs of the real script with PM_AGG_SOURCE=fixtures and an isolated PM_AGG_DIGESTS_DIR, same pattern as test/generate-digest-kind-6926.test.ts):

Invocation Observed
--kind weekly --no-deliver (control) exit 0, weekly-2026-11-08.json archived, no delivery attempt
--knd weekly --no-deliver (typo) exit 0, daily-2026-11-08.json archived — the weekly request silently became a daily digest
--bogus --no-deliver exit 0, daily digest archived — unknown flag ignored
--kind weekly --no-delivre (typo) weekly archived, then the delivery path ran anyway (proceeded to fetch push subscriptions from Supabase; probe run exited 1 on that fetch) — the operator's do-not-deliver instruction was silently dropped
--kind weekly --kind daily --no-deliver exit 0, weekly archived — duplicate flag silently first-wins

Why it matters

This script is run by systemd timers (daily/weekly digest) and by hand. Its two failure modes are both silent and one is irreversible:

  1. A typo'd kind produces and archives the wrong digest under the wrong date route (/digest/<date> renders the archive verbatim), with exit 0 — automation and operators see success.
  2. A typo'd --no-deliver sends Web Push notifications to every stored subscription that the operator explicitly meant to suppress. A sent push cannot be unsent.

This is the same defect class fixed per-script in #6961 (append-usage-snapshots), #6967 (compact-usage-snapshots) and #6973 (backfill-usage-snapshots) — reject unknown arguments before any I/O — and the value-guard half for this script was already fixed in #6926. The unknown-token half was left behind here.

Acceptance criteria

  • Any argv token that is not --kind (with its value), --no-deliver, or --strict-deliver is a usage error: message + USAGE on stderr, exit 2, before any archive write or delivery attempt.
  • A duplicate --kind is rejected (or otherwise explicitly handled), not silently first-wins.
  • Regression tests in the style of test/generate-digest-kind-6926.test.ts cover: unknown flag, typo'd --knd, typo'd --no-delivre (asserts no delivery attempt / exit 2 / nothing archived), and the valid control invocations still pass.
  • Existing generate-digest-kind-6926 tests still pass.

Activity

  1. developing-today commented on Nov 8, 2026

    @developing-today
    Contributor
  2. 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
    priority/normalOrdinary priority (the default)
    effort/xsTrivial: expected under 30 minutes of work
    app/aggregatorPackage/app: aggregator (pm-stack in this repo)
    work/self-assignedAn agent grabbed this item directly, outside the queue
    on Nov 8, 2026
  3. dezren39 commented on Nov 8, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

  4. dezren39 commented on Nov 8, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

    • Agent: new-issue-creator (creator-b lane)
    • Session / ID: new-issue-creator-code-b run 2026-11-07 21:50 CST
    • Found via: self-assigned during new-issue-creator-code-b run (guarded self-solve, lifecycle protocol §4: filed this run, trivial, no safety labels)
    • Task: Implement strict unknown/duplicate argument rejection in pm-stack/aggregator/scripts/generate-digest.ts + regression tests, branch creator-b/7097-digest-unknown-args.
    • Expectation: effort/xs — done = PR merged with tests green on branch and merged main.
    • Links: branch creator-b/7097-digest-unknown-args (to come)
  5. added a commit that references this issue on Nov 8, 2026
  6. dezren39 commented on Nov 8, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done

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)effort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus: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