Skip to content

fix(aggregator): validate burn segment values in isBurnSegment (#3428) - #4179

Merged
dezren39 merged 1 commit into
mainfrom
queue/6081-3428-burn-segment
Nov 2, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/6081-3428-burn-segment

Conversation

@dezren39

@dezren39 dezren39 commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Implements the fix for #3428 (queue task 6081; triage task 5319 confirmed the bug on main).

Problem

isBurnSegment in src/feed.ts checked only types, so negative token counts, non-date from/to, impossible calendar dates (2026-02-30), and inverted ranges passed as well-formed burn history and rendered on the quota page as measured data.

Change

The guard now validates values with the package's existing strict primitives from src/validate.ts:

  • isIsoDate on both from and to (real ISO calendar dates, not just strings),
  • isNonNegative on tokens,
  • a from <= to range check.

Malformed segments drop individually in sanitizeQuotaView with droppedBurn counting them — the existing #2429 behavior for shape failures, now covering value failures too. Out of scope per the issue: the isQuotaWindow gap (#3427) and the snapshot rollup guard (#3365).

Tests

New regression test beside the existing "malformed burn segments drop individually" test in test/feed.test.ts: negative tokens, garbage from, impossible to, and an inverted range each fail the guard, drop, and count; the well-formed segment fixture is unchanged and still passes. Suite: bun test test/feed.test.ts — 38 pass, 0 fail.

Refs #3428.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

The guard checked types only, so negative tokens, non-date from/to, impossible calendar dates (2026-02-30) and inverted ranges passed as well-formed burn history and rendered on the quota page. It now uses the package strict primitives — isIsoDate for both endpoints, isNonNegative for tokens — plus a from <= to check. Malformed segments drop individually in sanitizeQuotaView with droppedBurn counting them, the existing #2429 behavior extended from shape failures to value failures.

Regression test beside the existing drop test: negative tokens, garbage from, impossible to, and an inverted range all fail the guard, drop, and count; the well-formed fixture is unchanged. test/feed.test.ts: 38 pass, 0 fail.

Queue task 6081.
@dezren39
dezren39 requested a review from a team as a code owner November 2, 2026 05:01
@coderabbitai

coderabbitai Bot commented Nov 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 15 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 81e11c50-9687-44ec-b3d4-326c430da482
Commits

Reviewing files that changed from the base of the PR and between 3f06639 and a7126b0.

Files selected for processing: 2
  • pm-stack/aggregator/src/feed.ts
  • pm-stack/aggregator/test/feed.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T05:03:25.699348Z a7126b0 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant