8000 fix(migrate): skip imported answers without usage in the usage backfill by geminixiang · Pull Request #165 · geminixiang/mikan · GitHub
[go: up one dir, main page]

Skip to content

fix(migrate): skip imported answers without usage in the usage backfill - #165

Merged
geminixiang merged 2 commits into
mainfrom
fix/usage-missing
Oct 9, 2026
Merged

geminixiang merged 2 commits into
mainfrom
fix/usage-missing

Conversation

@geminixiang
Copy link
Copy Markdown
Owner

Deploying 1.3.0-beta.0 stopped at mikan migrate: step 0013-session-usage failed with Cannot read properties of undefined (reading 'input'), and the deploy rolled back to 1.2.2.

Cause

Some answers imported from 0.5.3 have no usage record (on the deployment: 144 of about 197,000 assistant answers, all without a stop reason). The backfill added their token counts. The Admin portal's daily chart reads the same answers through SessionStore.ownResponseUsage, so a session holding one was silently left out of the chart.

Change

Both readers skip an assistant answer without a usage record, counting it as no spend. The step's partial run is safe to repeat: sessions it already recorded carry importedUsage and are skipped.

Verification

  • Failing test first: an imported answer without usage next to one with usage. Before: the migration threw the deployment's error. After: the session records the one answer's 12 tokens, and the daily chart lists one answer.
  • Full gate.

Not on the Slack message path (migration step and Admin portal), so CI only.

Answers imported from 0.5.3 can lack a usage record. The 0013-session-usage step read their token counts and stopped, and the Admin portal's daily chart dropped every session holding one. Both now skip them as no spend.
@geminixiang
geminixiang merged commit 43609c3 into main Oct 9, 2026
2 checks passed
@geminixiang
geminixiang deleted the fix/usage-missing branch October 9, 2026 16:08
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

0