Skip to content

fix(routing): normalize analytics usage rows - #744

Closed
luvs01 wants to merge 1 commit into
devfrom
codex/propose-fix-for-routing-analytics-crash
Closed

luvs01 wants to merge 1 commit into
devfrom
codex/propose-fix-for-routing-analytics-crash

Conversation

@luvs01

@luvs01 luvs01 commented Oct 22, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Prevent a robustness regression where routing analytics passed shallow-parsed row_json through an attempt-aware pricing helper that assumed attempts was a real array, which could throw a TypeError for malformed persisted rows.

Description

  • Use the canonical persisted-usage normalizer by importing normalizePersistedUsageRow and applying it in parseEntry so decoded row_json is validated/normalized before any pricing logic runs in successCostUsd (src/routing/analytics.ts).
  • Extend the routing analytics regression test to include a malformed successful historical row (attempts: { length: 1 }) and adjust expectations so analytics completes and counts the row (tests/routing/routing-analytics.test.ts).
  • Changes affect src/routing/analytics.ts and tests/routing/routing-analytics.test.ts only and preserve existing analytics semantics for well-formed rows while dropping or repairing unsafe fields from malformed rows.

Testing

  • Ran the focused test file with bun test tests/routing/routing-analytics.test.ts, which passed (12 tests, 0 failures).
  • Ran type checking with bun x tsc --noEmit, which passed.
  • Attempted bun run test:changed but it could not run in the current environment because the local bun runtime available to the test harness is older than the repository's required test runner (bun 1.4.3).

Codex Task

@coderabbitai

coderabbitai Bot commented Oct 22, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • 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

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Oct 22, 2026
@luvs01

luvs01 commented Oct 22, 2026

Copy link
Copy Markdown
Owner Author

Verified commit c294f40130bdbada4bc1e8624ca4c63e648bc7a5, its two-file diff, and successful exact-head CI. The identical change is preserved in the maintainer review submission, with no unique work remaining in this duplicate PR. Closing this review container while retaining the source branch; the fix has not yet been declared merged or released.

@luvs01 luvs01 closed this Oct 22, 2026
@github-actions
github-actions Bot deleted the codex/propose-fix-for-routing-analytics-crash branch November 5, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant