GeezerVison is showing github.com — aggregator(coverage): CoverageSnapshotStore.read accepts a malformed baseline/weekly — diffCoverage then throws on /projects instead of the snapshot reading as absent · Issue #4140 · developing-today/code
aggregator(coverage): CoverageSnapshotStore.read accepts a malformed baseline/weekly — diffCoverage then throws on /projects instead of the snapshot reading as absent #4140DescriptionBug
pm-stack/aggregator/src/coverage.ts: CoverageSnapshotStore.read() is documented as "corrupt reads as absent" (coverage.ts:214, class comment: "Thin JSON store for the coverage snapshot; corrupt reads as absent"), but its only validation (coverage.ts:222-232) is:
const parsed = JSON.parse(await readFile(this.file, "utf8")) as CoverageSnapshotFile;
if (!parsed || typeof parsed !== "object" || !parsed.current || !Array.isArray(parsed.current.repos)) {
return null;
}
return parsed;
baseline and weekly are never checked, and neither are the row fields of any report. A snapshot file whose current.repos is an array but whose baseline is malformed is accepted as a good snapshot, carried through nextCoverageSnapshot (coverage.ts:199-212, which copies stored.baseline / stored.weekly verbatim into the next file — and promotes weekly to baseline at the weekly rotation), and then crashes the consumer:
diffCoverage (coverage.ts:168-183) does baseline.repos.map(...) unconditionally — a baseline that is a string, or an object without a repos array, throws TypeError there;
- that call sits on the /projects render path:
coverageSectionHtml in render.ts (diffCoverage at render.ts:5610) and coverageSnapshot() in server.ts:109-128, which feeds the stored snapshot into nextCoverageSnapshot on every panel read;
- a baseline whose rows carry garbage field types (e.g.
openIssues: "ten") survives too and produces NaN deltas (deltaOrNull subtracts unchecked values) that render as (NaN) in the panel.
The snapshot file is exactly the kind of artifact that drifts: the format already grew optional weekly / anchorAt fields with explicit "files written before the field existed" fallbacks (coverage.ts:62-73), so older/hand-edited/partially-migrated files are an anticipated input — the sibling roadmap-annotations store validates every row on load (isAnnotation, roadmap-annotations.ts:76-89) and quarantines a bad file instead of trusting it.
Evidence (verified this run, main @ bc0afe2)
Laptop probe ~/git/fleet/probe-2026-11-01-laneB-projcov/ (verbatim coverage.ts, md5 e17585a5fee1a752a9be91911a9e79ea; store files written to a temp dir, then read() → nextCoverageSnapshot(...) → diffCoverage(...)):
control (well-formed baseline/current/weekly) -> read() NON-NULL, diffCoverage OK, 1 delta entry
baseline: "junk" (string) -> read() NON-NULL (accepted); diffCoverage THREW TypeError: undefined is not an object (evaluating 'baseline.repos.map')
baseline: {generatedAt} (no repos) -> read() NON-NULL (accepted); diffCoverage THREW TypeError (same)
baseline: {repos: "nope"} -> read() NON-NULL (accepted); diffCoverage THREW TypeError: baseline.repos.map is not a function
baseline row fields garbage ("ten", null, {}) -> read() NON-NULL (accepted); diffCoverage OK but deltas are NaN
file containing "{not json" -> read() null (absent) — the documented behaviour, only for unparseable JSON
Why it matters
One malformed stored snapshot permanently breaks the /projects coverage panel: the bad baseline is re-persisted by coverageSnapshot() on every read (it only writes when the snapshot "changes", and the poisoned baseline is part of the compared shape), and the weekly rotation can promote a malformed weekly into the baseline slot. The store's own contract says this input should read as absent and self-heal with a fresh snapshot; instead it is a recurring render crash with no recovery short of deleting the file by hand.
Acceptance criteria
-
CoverageSnapshotStore.read() validates the whole file shape — current, baseline (when non-null), and weekly (when present) are each either null/absent or a report object with a string generatedAt and a repos array whose rows carry a string repo and number-or-null count fields — and returns null (absent) for anything else, per its documented contract.
- Files written by the current writer (including pre-
weekly/pre-anchorAt files, which rely on the documented fallbacks) still read back exactly as today.
- A malformed
weekly can no longer be promoted into baseline by nextCoverageSnapshot rotation, because the store never hands one out.
- Tests in
pm-stack/aggregator/test/coverage.test.ts: store reads for a string baseline, a baseline without repos, a non-array repos, and garbage row field types all return null; the existing concurrent-write test still passes.
- Existing aggregator tests still pass.
Dedup: #3364 (closed) covered the feed-side census gate (isRepoCensus) letting impossible census rows into a snapshot; this is the separate file-side read path — the stored snapshot's own baseline/weekly/current shapes are never validated on load. Searches for CoverageSnapshotStore / diffCoverage / "coverage snapshot" return no issue covering it. Activityadded kind/bugSomething isn't working (prefixed form of the classic bug label) task/triageQueue packet kind: verify, reproduce, and route this item effort/sSmall: expected under 2 hours of work on Nov 2, 2026dezren39 commented on Nov 2, 2026 🤖 Agent note · filed
- Agent: new-issue-creator-code-b
- Session / ID: new-issue-creator-code-b cron run 2026-11-01 20:50 CST
- Found via: filed this run — read
pm-stack/aggregator/src/coverage.ts on main bc0afe2f and verified with a verbatim copy run on the laptop (probe ~/git/fleet/probe-2026-11-01-laneB-projcov/, coverage.ts md5 e17585a5fee1a752a9be91911a9e79ea): snapshot files with baseline "junk", {generatedAt} (no repos), or {repos:"nope"} all passed CoverageSnapshotStore.read() and then threw TypeError in diffCoverage (baseline.repos.map); garbage row field types yielded NaN deltas; only unparseable JSON read as absent. Dedup: aggregator(coverage): isRepoCensus accepts impossible census rows — negative counts, gate counts above the open total, '/' repos and silent duplicate overwrite — and they persist into the weekly snapshot baseline #3364 (closed) covered the feed-side isRepoCensus gate, not this file-side read path; searches for CoverageSnapshotStore/diffCoverage found no covering issue.
- Task: Filed this issue: CoverageSnapshotStore.read accepts a malformed baseline/weekly — diffCoverage then throws on /projects instead of the snapshot reading as absent.
- Expectation: effort s; done when read() validates current/baseline/weekly report shapes (string generatedAt, repos array, typed rows) and returns null for anything else, pre-weekly/anchorAt files still read identically, and coverage.test.ts pins the malformed-baseline reads.
- Links: aggregator(coverage): CoverageSnapshotStore.read accepts a malformed baseline/weekly — diffCoverage then throws on /projects instead of the snapshot reading as absent #4140
developing-today commented on Nov 7, 2026
Picked up by repo-worker-code-b (Lane B queue worker, FALLBACK MODE — queue backend down, code#6619; fleet queue fallback subcommand absent in fleet 0.1.0, protocol run manually; comments via the developing.today GitHub App route while the user token is secondary-rate-limited). Lane code-f triaged CONFIRMED and released free at 2026-11-07T03:55:30Z; this claim takes the routed small-fix. No open PR covers #4140 (fresh search this claim).
🤖 Agent note · picked up
developing-today commented on Nov 7, 2026
Heartbeat — stage: implementation_complete. Laptop worktree ~/git/fleet/fb-4140 (branch queue/fallback-4140-coverage-snapshot-validation from current main): CoverageSnapshotStore.read() now gates the parsed file through isCoverageSnapshotFile — current must be a report (string generatedAt, repos array, rows with string repo and finite-number-or-null counts); baseline/weekly may be null/absent (documented fallbacks preserved) but must be reports when present; anything else reads as absent. bun test test/coverage.test.ts: 24/24 pass, including 3 new #4140 read tests and the existing concurrent-write test. Next: commit, push, PR, Codex gate.
developing-today commented on Nov 7, 2026
Released — outcome: done. Summary: fixed_merged via PR #6781 (merge commit 369710f, verified by fresh gh api + gh pr view readbacks) — CoverageSnapshotStore.read() now validates the whole snapshot file shape via isCoverageSnapshotFile and reads malformed files as absent, per its documented contract; pre-weekly/pre-anchorAt fallbacks preserved. Laptop: bun test test/coverage.test.ts 24/24 pass (3 new #4140 read tests + existing concurrent-write test). Codex on the PR head: completed, no findings. PR CI checks remained QUEUED (runner backlog) at merge, per standing merge authority. Issue #4140 closed by the PR (Fixes #4140); queue/work/status labels cleaned by this release.
🤖 Agent note · done
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|