Repository navigation
fix: normalize new /teams/spend response shape - #23
Merged
Merged
Conversation
Cursor's /teams/spend now returns spendCents as the overage above the plan, exposes the cycle total as overallSpendCents and no longer sends includedSpendCents. The collector crashed with a NOT NULL violation on spending.included_spend_cents and would have stored 0 spend for users within plan. Normalize each member so spendCents stays the cycle total and includedSpendCents is derived (total - overage), keeping pre-2026 responses working. Tests cover both shapes. Fixes ofershap#19. Based on Marc Cobery's f15dab2 (proposed in ofershap#21, closed unmerged). Co-authored-by: Marc Cobery <coberym@ae.com> Co-authored-by: Cursor <cursoragent@cursor.com>
The top-model query filtered on `ue.timestamp` (via the shared dateFilter) but selected FROM usage_events without the `ue` alias, so SQLite failed with "no such column: ue.timestamp". getUserCostDrivers is used by the z-score and trend detectors, so anomaly detection broke. Alias the table and qualify the selected/grouped column, and add a regression test. Co-authored-by: Cursor <cursoragent@cursor.com>
|
🎉 This PR is included in version 1.24.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #19.
Changes
1. Normalize the new
/teams/spendresponse shapeCursor changed
/teams/spend:spendCentsis now the overage above the plan, the cycle total moved tooverallSpendCents, andincludedSpendCentsis gone. The collector crashed withNOT NULL constraint failed: spending.included_spend_cents, and even past that it would have stored 0 spend for every user within plan.getSpendingnow normalizes each member so downstream code keeps its contract:spendCents=overallSpendCents ?? spendCents(cycle total)includedSpendCents=includedSpendCentsif present, otherwisemax(0, total - overage)Pre-2026 responses keep working. Tests cover both shapes, and
.cursor/rules/cursor-api.mdcdocuments the new response.2. Fix the top-model query in
getUserCostDriversThe query filters on
ue.timestamp(shareddateFilter) but selectedFROM usage_eventswithout theuealias, so SQLite threwno such column: ue.timestamp.getUserCostDriversis used by the z-score and trend detectors, so anomaly detection failed. Includes a regression test. This is a separate bug from #19; happy to split it into its own PR if you prefer.Credits
Commit 1 is based on @mcobery's work in #21 (closed unmerged), reduced to the minimal fix: no
.vscode/launch.json, no fetch error wrapping, no extraupsertSpendingdefaults (the normalization already guarantees the values) and no unusedMemberSpendfields. He is credited as co-author.Checks
npm run typecheck,npm run lint,npm testandnpm run buildpass on Node 22.Note: #22 touches some of the same files.