Repository navigation
fix(stats): ignore requests rejected before routing - #59773
Conversation
There was a problem hiding this comment.
The change looks sound. Both lake queries, usage/geo and retention, now share the same attempts > 0 guard, placed next to the existing product filter. A request rejected before routing can no longer create a model dimension or a /data page.
I couldn't run this against the R2 lake: there's no access from the review environment, and the lake schema isn't in the repo. So I couldn't confirm that attempts is a column there, or that rows with attempts = 0 never carry usage. If that holds, token and cost totals are unchanged.
bun test src/domain in packages/stats/core passes (34 tests), and tsc --noEmit is clean. The package's typecheck script (bun check --no-script) fails with "Script not found" on the base branch too, so that's unrelated to this change.
Public API: unchanged.
Co-authored-by: adamdotdevin <2363879+adamdotdevin@users.noreply.github.com>
Problem
The stats sync counted every Go/Free
generation.completedevent, including requests rejected before routing (attempts = 0). Those requests have no route, no endpoint and no usage, but theirmodel_requestedstring still became a model dimension and got a page on/data.One rejected request on 2026-09-19 for the nonexistent
glm-5.5-flash(HTTP 400, 0 attempts, no workspace) produced/data/zhipuai/glm-5.5-flash. That page is now being shared as evidence of an upcoming model.Change
attempts > 0to the source filter of the usage/geo and retention queries, so only requests that reached an upstream route are counted.R2 check: across all
generation.completedrows since 2026-05-28, everyattempts = 0row has no route, failed, and has null usage, andattemptsis never null. The filter therefore drops no tokens or cost.Effects
attempts = 0events after 2026-09-20 13:44 UTC. For current traffic, this is a guard rather than a behavior change.glm-5.5-flashrow stays until it leaves the 56-day window (about 2026-11-14) unless it is added to theStatsHiddenModelssecret.Verification
bun test src/domaininpackages/stats/core: 34 pass, including the new query testbun run typecheckinpackages/stats/coreRequested by: @adamdotdevin (Adam via Slack)