Repository navigation
Description
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--kindviaprocess.argv.indexOf(...)only; any other--flagtoken is never examined.- Delivery suppression is
process.argv.includes("--no-deliver")(:77) and strict mode isprocess.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:
- 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. - A typo'd
--no-deliversends 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-deliveris a usage error: message + USAGE on stderr, exit 2, before any archive write or delivery attempt. - A duplicate
--kindis rejected (or otherwise explicitly handled), not silently first-wins. - Regression tests in the style of
test/generate-digest-kind-6926.test.tscover: 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-6926tests still pass.
Activity
developing-today commentedon Nov 8, 2026
CODE-2248
dezren39 commentedon Nov 8, 2026
🤖 Agent note · filed
dezren39 commentedon Nov 8, 2026
🤖 Agent note · picked up
Merge pull request #7099 from developing-today/creator-b/7097-digest-…
dezren39 commentedon Nov 8, 2026
🤖 Agent note · done