Skip to content

fix(ccusage): accept period key from current ccusage#2732

Open
mvanhorn wants to merge 1 commit into
rtk-ai:developfrom
mvanhorn:fix/ccusage-period-key
Open

fix(ccusage): accept period key from current ccusage#2732
mvanhorn wants to merge 1 commit into
rtk-ai:developfrom
mvanhorn:fix/ccusage-period-key

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

rtk cc-economics currently fails with missing field month (serde: missing field month) because ccusage renamed its per-record key from month/date/week to period. The deserializer in src/analytics/ccusage.rs still required the old names, so every record fails to parse and the feature is unusable.

Changes

  • Add #[serde(alias = "period")] to the key field of DailyEntry, WeeklyEntry, and MonthlyEntry. This accepts the current period key while staying backward-compatible with older ccusage output that still emits month/date/week. No other behavior changes.

Tests

  • Added period-shape parse tests for daily, weekly, and monthly.
  • Existing legacy-key tests remain green.
  • cargo fmt --all, cargo clippy --all-targets, and cargo test --all all clean (2290 passed).
  • Verified end-to-end: cargo run -- cc-economics now renders against live ccusage with no parse error.

Closes #2731

@rtk-release-bot rtk-release-bot Bot added the wrong-base PR targets master instead of develop label Jun 29, 2026
@rtk-release-bot

Copy link
Copy Markdown
Contributor

Automatic message from CI checks : It seems like this branch is targeting the wrong branch, any contribution should target develop branch.

See CONTRIBUTING.md for details.

@rtk-release-bot

Copy link
Copy Markdown
Contributor

Automatic message from CI checks : It seems like this branch is targeting the wrong branch, any contribution should target develop branch.

See CONTRIBUTING.md for details.

ccusage renamed the per-record key from month/date/week to `period`, so
the deserializer's required old field names no longer match and
`rtk cc-economics` fails with "missing field `month`".

Add `#[serde(alias = "period")]` to the daily/weekly/monthly key fields
so both legacy and current ccusage output parse. Adds period-shape tests
for all three granularities; existing legacy-key tests stay green.
@mvanhorn mvanhorn changed the base branch from master to develop June 29, 2026 14:30
@mvanhorn mvanhorn force-pushed the fix/ccusage-period-key branch from 07d1e0d to d0a77cd Compare June 29, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wrong-base PR targets master instead of develop

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cc-economics: ccusage JSON parse fails (expects month, ccusage now emits period)

1 participant