Repository navigation
fix(api): an app in no organization with an organization's id leaves its limits to support - #2400
Merged
Merged
Conversation
kanat
reviewed
Nov 25, 2026
kanat
left a comment
Collaborator
There was a problem hiding this comment.
VERDICT: GO
Reviewed 486abb5 merged onto current main (b86e02f). CI on the head: all checks pass, Integration (router) included.
No Blocker and no Should fix. There are two Questions, inline. Neither blocks the merge: both are about behaviour that was already there before this PR, and they belong to the rest of AI-3765.
What I checked
- All 12 customer operations that take limits go through
limitsCaller: list, create, get, update, delete, usage, reset, grant create, grant list, revoke, unrevoke andGET /v1/teams. The manage operations do not. No other path keys limit rows by the app's own id.getSpendwithscope=organizationreads only the app's own spend, and account and policies need an organization. - Mutations: 21 checked, 0 survived. 9 change the logic of
limitsCaller,sharedIDandrecordOrganization: drop the record, record after the answer in a goroutine, always upsert, record only an app with no record, ignore the lookup or upsert error, droplen(members) > 0, drop!slices.Contains, let asharedIDerror through. 12 switch one call site at a time back to the base'slimitsCaller. Each one fails a test inSelfHostedLimitsSuite. LimitsSuite,SelfHostedLimitsSuite,AccountSuite,SelfHostedAccountSuiteandPoliciesSuitepass on the merged tree.go vet -tags integration ./internal/api/and gofmt are clean, andopenapi.yamland the JS types match their source.- A self-hosted app in no organization, with no organization of its id, behaves as before. The only change for it is one more read,
Members. recordOrganizationruns for the same request asEnforcer.Join, with the same organization, so the two writes agree. Its errors take the 500 path. The 403 text is fixed words and holds no deployment settings.- There is no migration, no new dependency and no spec change. No skill or doc line still describes the old rule.
kanat
approved these changes
Nov 25, 2026
kanat
left a comment
Collaborator
There was a problem hiding this comment.
Approving on the reviewer's GO (#2400 (review)).
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.
Problem
For its spend limits, an app in no organization is its own organization, by its own id. Nothing said who manages the limits kept under an id that is also an organization's.
Fix
limitsCalleranswers an app in no organization 403forbiddenwhen its id is also an organization's it is not in (sharedID). This covers every customer operation on limits, usage, resets, grants andGET /v1/teams, with one message whatever the request names. They all declare 403, so the spec does not change.Members(AI-3735: no foreign app by organization id in teams #2383); the app is in it when it is one of them. The read goes to Postgres, not the cache.Enforcer.Joindoes it in the background, and once per router. An app recorded there already costs one read by primary key. A lookup or a record that fails answers 500.Tests
SelfHostedLimitsSuite(limits_shared_id_test.go): over HTTP, one test per operation, in which the app is refused and the organization is not; with an organization known by a registration, of two apps, or seen later, an app seen elsewhere, and one no longer in its own. A limit and a grant made by an app recorded elsewhere are its organization's. These fail without the change, as do the two on a lookup or a record that fails.TestAnAppInTheOrganizationOfItsOwnIdKeepsItsLimits,TestALimitOfASharedIdHoldsTheAppsWorkAndTheOrganizations,TestStaffManageTheLimitsOfASharedIdandTestStaffsLimitRecordsNoApppass without it too: they hold what does not change.TestAnAppRecordedInItsOrganizationIsNotRecordedAgainholds the new record to a mismatch.TestAnAppInNoOrganizationReadsOnlyItself,TestAnAppInNoOrganizationsOrganizationIsItselfAloneandTestAnAppInNoOrganizationsTeamsAreItsOwnWorksnow record the app in the organization of its own id, so that they still reach the reads they check.TestAnAppReadsItsOwnSpendWhateverOrganizationIsRecordedForItmoves the record in the middle of the read;TestAnAppWithAnOrganizationsIdKeepsTheLimitsOfTheOneItNamesholds the check to requests that name none.Part of AI-3765