Repository navigation
Description
Problem
pm-stack/aggregator/scripts/post-alert.ts — the one CLI every sentinel uses to post to the alert throat (#3676) — reads each flag with a bare process.argv.indexOf lookup (arg(), scripts/post-alert.ts:40-41) and never scans argv for anything else. Unknown, misspelled, joined (--flag=value), duplicated, and stray positional arguments are silently ignored:
--severityfalls back to"critical"when the flag is not found verbatim (scripts/post-alert.ts:55), so a typo'd flag name silently escalates the incident.- An unrecognized token and its value are consumed by nothing and reported by nothing; the post proceeds with exit 0.
This is the one aggregator script left out of the settled unknown-args class: append-usage-snapshots.ts (#6961), compact-usage-snapshots.ts (#6967), backfill-usage-snapshots.ts (#6973), generate-digest.ts (#7097), and collect-github-billing.ts (#7254) all gained rejectUnknownArgs() (usage error, exit 2, before any I/O). post-alert.ts got the flag-as-value guard in #3723 but never the unknown-args scan, and it has no positional-argument contract at all.
Evidence (verified this run)
Probe on the laptop, ~/git/fleet/probe-post-alert-unknown-args (probe.test.ts): the real script run verbatim as a subprocess (current main a23b3ce454, md5 de4a732f8cdf4c51e7452a30ef564198) against a stub intake server (Bun.serve) and a stub bws, in the exact style of the shipped test/post-alert-args-3723.test.ts. Oracle = the captured POST body + exit code.
Control passes: --source watch --key h1 --severity warning --title "host down" --body 503 → exit 0, posts {"severity":"warning",...,"body":"503"}.
With a misspelled / unknown / joined argument, the script posts anyway, exit 0:
- Typo'd flag name
--severty warning→ posts{"source":"watch","key":"h1","severity":"critical","title":"host down"}— a warning incident silently filed as critical (critical incidents push immediately to subscribed browsers and escalate when unacknowledged; warnings do not — src/alerts.ts / src/render.ts alert-throat behavior). - Joined form
--severity=warning→ same result: postsseverity:"critical", exit 0. - Unknown flag
--bogus x→ silently ignored; the incident posts, exit 0. - Typo'd optional flag
--bodi 503→ posts{"severity":"info","title":"host down"}with nobodyfield at all — the diagnostic body is silently dropped. - Stray positional
extraafter the documented flags → silently ignored; the incident posts, exit 0.
Why it matters
post-alert is the fleet's single alert throat: every sentinel posts through it instead of inventing its own path. Its whole value is that the incident posted is the incident the caller named. A one-character typo in a sentinel's invocation today either (a) escalates a warning into a critical that pushes to browsers and pages on the ack window, training operators to ignore criticals, or (b) drops the diagnostic body that explains the incident — in both cases with exit 0, so the calling sentinel believes the alert was posted exactly as intended. The sibling scripts were fixed for precisely this failure shape; this CLI — the one whose output is an operator-facing alarm — is the remaining hole.
Acceptance criteria
-
post-alert.tsrejects any argument it does not recognize — unknown/misspelled flag names, joined--flag=valueforms, duplicated flags, and stray positional tokens — with a usage error naming the offending argument and exit 2, before any token is resolved or any fetch is made (therejectUnknownArgs()contract of aggregator(append-usage-snapshots): unknown or misspelled flags are silently ignored — a typo'd --from-provider-usage silently runs the wrong derivation mode and exits 0 #6961/aggregator(compact-usage-snapshots): unknown or misspelled flags are silently ignored — a typo'd --month 24 with --apply irreversibly compacts months the operator meant to keep raw #6967/aggregator(generate-digest): unknown/misspelled flags silently ignored — typo --knd archives a daily digest, typo --no-delivre delivers anyway #7097/aggregator(collect-github-billing): unknown/misspelled flags are silently ignored — a typo'd --yer collects the current month, and a typo'd --prnit turns a dry run into a real outbox append #7254). A flag's value token is consumed by its flag and is never itself scanned as an argument. - The documented invocations are unchanged: all five flags (
--source,--key,--severity,--title,--body) with space-separated values still post exactly the incident they name, and an omitted--severitystill defaults tocritical(both pinned by the existing aggregator(post-alert): the alert-intake CLI's arg() takes the next flag as a value — '--title --body x' posts a critical incident literally titled '--body' #3723 tests, which stay green). - New regression tests in the aggregator bun suite (extending
test/post-alert-args-3723.test.tsor a sibling file, subprocess + stub intake/bws in the established style) cover at least: typo'd--severty, joined--severity=warning, an unknown flag, a typo'd--bodi, a duplicate flag, and a stray positional — each asserting exit 2, no bws call, and no captured POST — and each failing on the pre-fix code. - No change to the intake request shape, the token resolution, or the server-side severity validation (src/alerts.ts already rejects non-enum severities; the defect is the CLI silently substituting the
criticaldefault for a flag the caller did write).
Dedup: searched open + closed issues for "post-alert" titles — #3723 covers the flag-as-value guard in the same arg() (fixed, different defect); no issue covers unknown/misspelled/joined/duplicate arguments for post-alert. The sibling fixes (#6961, #6967, #6973, #7097, #7254) each cover a different script.
Activity
developing-today commentedon Nov 8, 2026
🤖 Agent note · filed
Merge pull request #7295 from developing-today/creator-a/7289-post-al…
developing-today commentedon Nov 8, 2026
🤖 Agent note · fixed-merged (self-solved)
b7b7f596e4).rejectUnknownArgs()in scripts/post-alert.ts: every argv token must be one of the five documented value flags, each at most once — unknown/misspelled/joined/duplicate arguments and stray positionals are a usage error naming the token, exit 2, before any token resolution or fetch (mirrors aggregator(generate-digest): unknown/misspelled flags silently ignored — typo --knd archives a daily digest, typo --no-delivre delivers anyway #7097/aggregator(collect-github-billing): unknown/misspelled flags are silently ignored — a typo'd --yer collects the current month, and a typo'd --prnit turns a dry run into a real outbox append #7254). A flag's value token is consumed by its flag;arg()still validates it (aggregator(post-alert): the alert-intake CLI's arg() takes the next flag as a value — '--title --body x' posts a critical incident literally titled '--body' #3723 unchanged).test/post-alert-unknown-args-7289.test.ts+ the aggregator(post-alert): the alert-intake CLI's arg() takes the next flag as a value — '--title --body x' posts a critical incident literally titled '--body' #3723 suite: 5/5 pass on the branch and on merged main (laptop); the new regression test fails on the pre-fix script (control passes). Probe: ~/git/fleet/probe-post-alert-unknown-args (real script verbatim, stub intake/bws).gh issue createsilently no-opped andgh pr createhit the secondary rate limit; the issue and PR were filed via the developing.today App (fleet-paperwork / App token) per the rate-limit fallback, verified by readback each time.