GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — aggregator(github-billing): billing items never validated — an impossible date discards the whole month's collection, negative amounts are stored as usage · Issue #2493 · developing-today/code

aggregator(github-billing): billing items never validated — an impossible date discards the whole month's collection, negative amounts are stored as usage #2493

New issue
Copy link
New issue
Copy link
Closed
#3445
Closed
aggregator(github-billing): billing items never validated — an impossible date discards the whole month's collection, negative amounts are stored as usage#2493
#3445
Copy link
Assignees
dezren39
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/triageQueue packet kind: verify, reproduce, and route this item

Description

@dezren39
dezren39
opened on Oct 30, 2026
Issue body actions

Problem

aggregateBillingUsage in pm-stack/aggregator/src/sources/github-billing.ts:78-113 (the #1051 collector core, merged in PR #2236) validates almost nothing about the unified billing endpoint's items:

  • Date: the only check is typeof item.date === "string" && item.date.length < 10 skip (:81); the first 10 chars are taken verbatim (:82). "2026-13-99" and "2026-02-30" both pass.
  • Amounts: quantity, grossAmount, and netAmount are summed whenever typeof === "number" (:84, :99-100) — negative values pass; no finiteness or sign check anywhere in the file.

The two failure modes land in different places, and both are bad:

  1. One impossible date discards the whole month's collection. recordsFromBillingUsage (:149-168) stamps each day with dayTs(date) (snapshot-records.ts:32-34 — plain string interpolation, "2026-13-99T12:00:00Z"). Those records fail isSnapshotRecord (snapshots.ts:304, Date.parse is NaN), and the collector treats any invalid derived record as fatal: scripts/collect-github-billing.ts:84-86 throws and appends nothing — every good day in the month is lost because one item's date was malformed. A Feb-30 date is worse in the opposite direction: Date.parse rolls it over, so the record passes validation while carrying a literal nonexistent day as its ts (and dedupe key).
  2. Negative usage is stored as fact. A negative quantity/grossAmount/netAmount produces negative day aggregates, and the derived records (e.g. actions-minutes: -120, billing-gross: -0.96) pass isSnapshotRecord (finite is all it asks) and are appended to the snapshot store, corrupting the GitHub service's usage/billing series.

Sibling collectors in this repo all guard this: the Supabase exporter rejects negative/non-finite reads (parseDbSize, parseRequestCount in pm-stack/supabase-export/supabase-quota-export.mjs), and quota-gather-map.ts's num() is finite-gated. This file is the unguarded outlier.

Evidence (verified this run, main 7d1b081c)

Laptop probe (~/git/fleet/probe-2026-10-29-laneB-billing/probe2.ts, real github-billing.ts + snapshots.ts from a fresh clone at main, run with bun):

control (120 min, $0.96)            => day aggregates correct; 3 records, all isSnapshotRecord = true
quantity/gross/net all negative     => aggregates -120 / -0.96 / -0.96; records emitted with
                                       value -120 and -0.96, isSnapshotRecord = true for all (stored)
date "2026-13-99T00:00:00Z"         => day "2026-13-99" aggregates fine; records ts
                                       "2026-13-99T12:00:00Z", isSnapshotRecord = false for all
                                       => collector throws, whole month appended: nothing
date "2026-02-30"                   => records ts "2026-02-30T12:00:00Z", isSnapshotRecord = true
                                       (Date.parse rollover) — nonexistent day stored as-is
mixed good day + one month-13 item  => 6 records, only 3 valid — the good day is discarded with the bad one

Why it matters

This collector is the GitHub billing series' only writer. Either failure silently degrades it: a single malformed item from the endpoint (shape drift, a partial response, a future SKU/date format) zeros out a month of Actions/Codespaces/billing history with only a thrown error in a daily job log, and a negative row — which no downstream check rejects — permanently writes negative minutes/dollars into the snapshot store that quota views and reconciliation read.

Acceptance criteria

  • Items with a non-calendar date (month 13, Feb 30, non-date prefix) are rejected or skipped at aggregation time with the day/item identifiable — they never produce a record, and never take the month's good days down with them.
  • Negative (and non-finite, for direct API callers of the pure functions) quantity/grossAmount/netAmount values cannot produce negative aggregates or stored records; the chosen treatment (skip item vs skip field vs fail the run) is pinned by triage and documented in the file header.
  • The collector's all-or-nothing validation throw (collect-github-billing.ts:84-86) is reconsidered for whatever validation remains downstream: one bad item must not discard a month of valid records.
  • Regression tests in test/github-billing.test.ts cover: month-13 date, Feb-30 date, negative quantity, negative gross/net, and a mixed good+bad month that still yields the good days' records.
  • Well-formed items are unchanged: existing github-billing.test.ts expectations still pass.

Dedup: #1051 (closed) specified this collector; PR #2236 built it. #1540/#2483 concern the snapshot store validators (snapshots.ts pairs/limit/resetsAt) — this is the producer-side item validation in sources/github-billing.ts, which neither covers. Title/body searches for github-billing, aggregateBillingUsage, and "billing usage" returned no covering issue, open or closed.

Activity

Next
  1. developing-today commented on Oct 30, 2026

    @developing-today
    developing-todayBot
    on Oct 30, 2026 – with developing.today
    Contributor
    More actions

    CODE-1272

  2. dezren39
    added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    priority/normalOrdinary priority (the default)
    queue/queuedHas a queued queue task
    source/creatorFiled by the new-issue-creator job
    task/triageQueue packet kind: verify, reproduce, and route this item
    status/needs-triageNot yet triaged; needs a first look
    app/aggregatorPackage/app: aggregator (pm-stack in this repo)
    effort/xsTrivial: expected under 30 minutes of work
    on Oct 30, 2026
  3. dezren39 commented on Oct 30, 2026

    @dezren39
    dezren39
    on Oct 30, 2026
    MemberAuthor
    More actions

    🤖 Agent note · filed

    • Agent: new-issue-creator job, lane B (new-issue-creator-code-b)
    • Session / ID: cron new-issue-creator-code-b, run 2026-10-30T01:20Z
    • Found via: filed this run
    • Task: Triage the github-billing item-validation gap (impossible dates discard the whole month's collection; negative amounts stored as usage) and route a fix packet.
    • Expectation: effort/xs — done when the acceptance criteria on the issue are met (bad items rejected/skipped without losing good days, no negative records, regression tests, well-formed items unchanged).
    • Links: probe on laptop ~/git/fleet/probe-2026-10-29-laneB-billing/probe2.ts (real modules, main 7d1b081)
  4. github-actions
    assigned
    dezren39
    on Oct 30, 2026
  5. dezren39
    added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed
    status/needs-triageNot yet triaged; needs a first look
    queue/queuedHas a queued queue task
    on Nov 1, 2026
  6. 2 remaining items

  7. dezren39 commented on Nov 1, 2026

    @dezren39
    dezren39
    on Nov 1, 2026
    MemberAuthor
    More actions

    🤖 Agent note · done (triage)

    • Agent: queue worker (repo-worker-code), Lane E shift
    • Session / ID: queue task 3732 (triage) → follow-up fix task 5350
    • Found via: queue claim
    • Task: Triage aggregator(github-billing): billing items never validated — an impossible date discards the whole month's collection, negative amounts are stored as usage #2493 — CONFIRMED at current main, layer + negative/non-finite treatment pinned, small_fix routed
    • Expectation: met — findings below; fix = queue task 5350
    • Links: fix packet: hidden_files/packets/task-2493-fix.json (goal workspace)

    Verdict: CONFIRMED at current main a11cfea3c (2026-11-01), with one behavior update vs the original filing.

    Evidence (fresh, this run):

    • src/sources/github-billing.ts aggregateBillingUsage: the date check is only typeof string && length >= 10, first 10 chars taken verbatim; quantity sums whenever typeof number; grossAmount/netAmount likewise. No calendar, sign, or finiteness check anywhere.
    • recordsFromBillingUsage (github-billing.ts:149-168) stamps each day via dayTs(day.date) and pushes every non-zero field as a snapshot record; scripts/collect-github-billing.ts:84-86 filters by isSnapshotRecord and throws if any derived record is invalid — appending nothing for the whole month.
    • Laptop Bun probe (real modules at a11cfea): control 3 records / 3 valid; 2026-13-99 → 3 / 0 valid (month lost); negative quantity → value −5, valid, stored; negative gross/net → −2/−3, valid, stored; NaN quantity → invalid record (month poisoned); mixed good+bad month → 6 / 3 valid, and the collector would throw away the good 3 too.
    • Update: 2026-02-30 → 3 / 0 valid. Since the original probe, isSnapshotRecord gained the strict isIsoDate ts gate (aggregator(snapshot-records): shape-only dates win freshestDate — a 2026-13-01 'Last checked' silently drops a pool's snapshot history, 2026-02-30 is stored as a phantom March date #2264/aggregator(snapshots): isSnapshotRecord never checks limit/resetsAt — a numeric resetsAt crashes the service history chart, a non-numeric limit NaNs it #2483), so Feb-30 no longer rolls over into a stored record — it has moved into the whole-month-loss class. Same fix covers it.
    • The store boundary does not catch this: isSnapshotRecord (snapshots.ts:296+) refuses negatives only for unit === "pct" (aggregator(derive): projectPace throws RangeError on validator-passing pct records — one poisoned snapshot breaks the quota card, service page, and service.json #2346), so negative minutes/hours/USD pass.

    Layer pinned — aggregation owns validation (aggregateBillingUsage, github-billing.ts); the collector is NOT given per-item tolerance (its all-or-nothing throw stays as a backstop for genuinely new bug classes):

    1. Date: skip the item when isIsoDate(date.slice(0, 10)) is false (validate.ts strict primitive — the same one the store gates on).
    2. Numeric fields, per-field: quantity / grossAmount / netAmount contribute only when finite and ≥ 0, else 0 — extending the existing non-number fallback. Negative consumption is never a legitimate endpoint semantic, a negative/non-finite field must neither be stored nor poison the month, and zeroing one field does not discard the item's other valid fields.
    3. Surfacing: the skip/zero count is exposed from the aggregation layer and printed in the collector's existing summary line when > 0 — never swallowed.

    Regression tests named in the fix packet (test/github-billing.test.ts): month-13 skipped with the rest of the month intact, Feb-30 skipped, negative quantity / negative gross-net zeroed per-field, NaN/Infinity zeroed, mixed month derives a 100%-valid record set, well-formed months unchanged.

  8. dezren39
    added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    status/in-progressQueue worker lifecycle state
    and removed
    status/in-progressQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    on Nov 1, 2026
  9. dezren39 commented on Nov 1, 2026

    @dezren39
    dezren39
    on Nov 1, 2026
    MemberAuthor
    More actions

    agent-note:v1
    state: claimed
    task: 5350 (repo-health-code-pilot, lane D)
    stage: pickup
    did: claimed small_fix; revalidated #2493 OPEN with no held/owned labels and no competing PR; aggregateBillingUsage at src/sources/github-billing.ts:78 matches the triage pin on main a11cfea.
    resume: implement the aggregation-boundary validation on a laptop worktree, test, open PR, merge when verified.

  10. dezren39
    added a commit that references this issue on Nov 1, 2026

    Merge pull request #3445 from developing-today/queue/5350-2493-billin…

    b09c9ce
  11. dezren39
    closed this as completedin #3445on Nov 1, 2026
  12. dezren39
    removed
    status/in-progressQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    on Nov 1, 2026
  13. dezren39 commented on Nov 1, 2026

    @dezren39
    dezren39
    on Nov 1, 2026
    MemberAuthor
    More actions

    agent-note:v1
    state: done
    task: 5350 (repo-health-code-pilot, lane D)
    stage: fixed_merged
    did: PR #3445 merged (merge commit b09c9ce); this issue auto-closed. aggregateBillingUsage now skips items whose date is not a real calendar date (isIsoDate) and counts quantity/grossAmount/netAmount only when finite and >= 0 (isNonNegative). Targeted tests 10/10 on the laptop worktree; Codex review completed with no findings.
    resume: none — terminal.

  14. developing-today
    added
    status:done
    on Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @dezren39
    dezren39

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/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.