fix(copilot): don't let a placeholder Extra Usage row block the org billing lookup#844
Merged
Merged
Conversation
…illing lookup The org-managed seat placeholder can carry overage_permitted: true on its zero-entitlement premium bucket, which emitted an "Extra Usage: 0" row and made mapped.lines non-empty — so the org-billing fallback (gated on lines.isEmpty) never ran (#839, second report). Extra Usage is now emitted only alongside a real Credits meter (overage is meaningless without an included pool), and the provider gates the org lookup on an explicit isOrgManagedSeat flag from the mapper instead of the incidental shape of the lines array. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
TL;DR
Follow-up to #843: the org-billing lookup for org-managed Copilot seats never ran for the #839 reporter because his placeholder response sneaks an "Extra Usage: 0" row into the mapped lines, and the lookup was gated on the lines being empty. The gate is now an explicit mapper flag, and the meaningless placeholder row is suppressed.
What was happening
GET /user/orgsin the logs.premium_interactionsplaceholder carriesoverage_permitted: true(with zero entitlement andunlimited: true), so the mapper emitted "Extra Usage: 0".mapped.linesnon-empty, so thelines.isEmptygate skipped the org-billing fallback entirely — his own diagnosis in the issue, confirmed in code.overage_permitted, which is why the tests passed while the real payload failed.What this changes
CopilotUsageMappernow returns an explicitisOrgManagedSeatflag (token-based billing + no usable per-seat meters), andCopilotProvidergates the org lookup on that flag instead of the incidental shape of the lines array.overage_permitted: trueon premium), so every org-path test exercises the regression; plus dedicated mapper tests for the placeholder-suppression and the flag.Tests
overage_permitted: true→ no Extra Usage row,isOrgManagedSeattrue, org lookup runs end-to-end; paid accounts with a real pool keep their Extra Usage row.Made with Cursor