Repository navigation
fix(api): resolve analytics and inventory accounts by provider and external id - #622
Merged
cristim merged 2 commits intoOct 6, 2026
Merged
Conversation
…ternal id Analytics scope checks and the inventory account name read a name map keyed by external id alone, so two accounts of different providers sharing an external id made the result depend on account list order: a raw account_id was allowed or refused by whichever account was listed last and then queried every provider's rows, and inventory rows showed another account's name. Analytics now attributes a raw external id only when exactly one account has it and refuses an ambiguous one; inventory resolves the name with the provider-qualified helper History uses (UUID, then provider plus external id, then a unique legacy match). Does not change AccountScope.Allows or name matching (#433). Refs #520
Contributor
|
Warning Review limit reached
This review includes 5 billable files and costs up to $1.25.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 27 minutes for your next included review. View limit detailsLimit details: You’ve used the included review currently available. Your 67 included PR review attempts over the past 7 days set your current allowance at 1 review per hour. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (5)
Comment |
Analytics scope checks and the inventory handler ignored a ListCloudAccounts error. Return it instead, and cover the unregistered raw id branch. Refs #520
7 tasks
This was referenced Oct 19, 2026
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.
Refs #520 (checklist item 3, non-#433 part). Does not touch
AccountScope.Allowsor name matching (#433).Problem
External ids are unique only per (provider, external_id). Two places still resolved accounts by external id alone (the
resolveAccountNamesByIDmap, last listed account wins), the same class as #593:validateAnalyticsAccountScope, used by /api/history/analytics, /api/history/breakdown, /api/analytics/trends): a rawaccount_idshared by an aws and an azure account was allowed or refused depending on account list order, and an allowed request queried the provider-unconstrained bucket, so rows of the other provider's account came back.listActiveCommitments): the row's account name came from the same map, so a row showed another account's name (including a tenant's name the caller cannot see). Row filtering was already provider-qualified by fix(api): match history rows to scoped accounts by provider and external id #593.Change
historyRowAccountName(CloudAccountID, UUID in AccountID, provider plus external id, unique legacy match).handler_inventory_test.gonow setsProvideron its accounts (the lookup is provider-qualified).Tests
New HandleRequest tests, both list orders, fail on main and pass here: shared id across providers (name scope, id scope, unrestricted), UUID rows, unique raw id unchanged, same-provider ambiguity fails closed. Mutations that fail them: take the first match on ambiguity; drop provider qualification; revert to the external-id-only name map.
go test -race -short ./...,go vet ./...,go vet -tags integration ./internal/...pass.Not in this PR
A scoped user passing a raw external id shared by two accounts now gets 404 instead of an order-dependent answer; the UI sends UUIDs. The other
resolveAccountNamesByIDcallers key by UUID only and are unaffected (see the issue checklist).Behavior change
ListCloudAccountsfailure in the analytics scope check (scoped users) and in inventory now returns an error. Before, analytics silently fell back to literal-id matching and inventory left the name blank.Known remaining exposure (analytics only), tracked as #624
QueryHistory, QueryBreakdown and the trends queries take the
{"": {ext}}bucket directly (account_id = ANY, no provider). A scoped user's unique registered raw id can also return rows of another provider's UNREGISTERED account with the same id (for example an AWS 12-digit id and a GCP project number). Registered accounts cannot collide. Dashboard, inventory and history are not exposed (intersectAccountFilterScope and intersectDualColumnScope re-group "" under the allowed provider). Follow-up: resolve the filter to {match.Provider: {id}} or intersect it like the other paths, handling legacy rows with an empty provider deliberately.