Repository navigation
Conversation
|
|
bugbot run Please review the current commit for daily public-model accounting, migration correctness, and PTU identity regressions |
… a backfill
The daily spend identity indexes and the writer's ON CONFLICT target use
COALESCE("model_group", ''), so rows stored with a NULL group before
model_group joined the key share one identity with the '' new writers store
and no historical row is rewritten. Prisma cannot declare an expression index,
so the three schema copies drop the @@unique and --use_prisma_db_push runs the
identity migration right after the push.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Keeps main's service-target imports beside the PR's writer-pinned client import in ptu_flat_cost_rollup.py; everything else merged cleanly. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…stead of a backfill" This reverts commit 29607f8. Prisma cannot declare the COALESCE expression index, so every database seeded by `prisma db push` outside the proxy's own startup (the proxy-behavior CI job, the e2e UI script) had no unique index on the daily spend tables and the writer's ON CONFLICT failed. The legacy NULL model_group duplicate stays a documented cutover caveat. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
@greptileai can you reply here with a score and why that score? |
|
bugbot run |
|
Score: 5/5 This looks safe to merge based on the current commit. The implementation consistently carries The migration updates the corresponding indexes across all six tables, and the runbook clearly documents the required maintenance-window cutover and incompatibility with old writers. PTU rows retain a stable deployment/day-derived ID while allowing the display name to change, avoiding duplicate charges on renames or concurrent rollups. The added tests cover nullable identity fields, deterministic merging, internal-call accounting across all entities, PTU legacy-row reuse, retries, concurrency, and dashboard zero-request behavior. The migration is operationally high-risk because index replacement blocks writes, but that risk is clearly documented and is not a correctness blocker for the PR. |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 7bc136d. Configure here.
Adds the row-count query, the per-million-rows estimate measured on a 3M-row table, the one-transaction write-freeze note, and the migrate deploy timeout variable to the model-group identity cutover section. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
TLDR
Problem this solves:
How it solves it:
Intentional product change: Usage shows N/A when there are no successful requests to average, and explains UTC daily totals
User Flow
Before: two public names can appear as one model in Usage
POST https://litellm-domain/v1/chat/completionsas the same key usingdirect-model, thenalternate-model, backed by one deploymenthttps://litellm-domain/ui/usage/and select the request dateAfter: Usage retains the separate public names and their totals
direct-modelandalternate-modelhttps://litellm-domain/ui/usage/and select the request dateRelevant issues
Changes
model_groupin all six daily queue, bulk-upsert and database identitiesLinear ticket
Resolves LIT-9198
Pre-Submission checklist
make check, discovery/shard guards and migration scanner pass locallyScreenshots / Proof of Fix
Real local proxies and isolated Postgres, using paid
moonshot/kimi-k3calls on 2026-10-03.direct-modelandalternate-modelshare a deployment. Each endpoint has a separate user/key.$PROXYishttp://127.0.0.1:4584before andhttp://127.0.0.1:4585afterThe User Flow screenshots show
http://127.0.0.1:3014/usage/before andhttp://127.0.0.1:3015/usage/after: open Usage, choose Model Activity, then Public Model NameSend each payload twice, replacing
<MODEL>with each public name:Before (5724117)
Chat Completions
direct-modelcontains both requests: 70 tokens/$0.000474;alternate-modelis absentAnthropic Messages
Responses
After (c6669ba)
Chat Completions
Anthropic Messages
Responses
The current migration was applied twice to the current base schema using real Postgres. Historical totals, nullable groups, repeated/concurrent writes across all six tables, and stable PTU IDs across renames passed
Type
Bug Fix
Caveats (if any)
Severe
Medium
model_groupby releases before 2026-08-19 keep their own row if the same identity is written again on the same UTC day after the cutover; totals stay correctLow
proxy-infrabraces@3.0.3advisory GHSA-vfj7-8cjw-p6xmNote
High Risk
Index replacement on production daily spend tables blocks writes and is incompatible with pre-cutover proxy writers; incorrect rollout can corrupt or duplicate attribution until reconciled.
Overview
Daily usage rollups now treat the requested public model group as part of the row identity for all six daily spend tables (user, team, org, end user, agent, tag), so two public names that share one deployment no longer merge into a single Usage row.
A migration replaces six unique indexes and updates the synced Prisma schemas. Bulk upsert and in-memory queue keys now use the same
conflict_keytuple (including normalizedmodel_group) as PostgresON CONFLICT. PTU flat-cost rows upsert by a stable deployment/day row id and only refreshmodel_groupon rename, so charges do not split when the display name changes.The migration runbook documents a maintenance cutover (drain buffers, stop old writers). The Usage dashboard shows N/A for per-request averages when there are zero successful requests and adds a short note that request counts exclude internal calls while spend/tokens include them.
Reviewed by Cursor Bugbot for commit 7bc136d. Bugbot is set up for automated code reviews on this repo. Configure here.