Skip to content

fix(api/inventory): show account name in Commitments view#953

Merged
cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/952-commitments-account-name
Jun 4, 2026
Merged

fix(api/inventory): show account name in Commitments view#953
cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/952-commitments-account-name

Conversation

@cristim
Copy link
Copy Markdown
Member

@cristim cristim commented Jun 4, 2026

Summary

  • resolveAccountNamesByID built its lookup map keyed only by CloudAccount.ID (UUID), but PurchaseHistoryRecord.AccountID stores the cloud-provider external ID (e.g. an AWS 12-digit account number), not the UUID. The map lookup always missed, so AccountName was always empty and omitted from the JSON (omitempty), causing the frontend Commitments table to fall through to the ID-only display path.
  • Fix: also index the map by CloudAccount.ExternalID so the purchase-history lookup path resolves the display name correctly. UUID callers (recommendation records using the cloud_account_id FK) continue to work via the UUID key unchanged.
  • Update two test fixtures to use realistic ID=UUID / ExternalID=legacy-account-id values so this regression cannot hide behind accidentally matching test values again.

Closes #952.

Test plan

  • go test ./internal/api/... -run TestHandler_listActiveCommitments -- all 5 tests pass, including the updated fixtures that now use UUID IDs and separate ExternalIDs
  • go test ./internal/api/... -- all 1428 backend tests pass
  • npx jest --testPathPattern=inventory (frontend) -- all 41 tests pass
  • npx tsc --noEmit -- no TypeScript errors

Summary by CodeRabbit

  • Bug Fixes

    • Improved account identification to correctly match cloud provider accounts with internal records, preventing account resolution errors (issue #952).
  • Tests

    • Updated test fixtures to validate enhanced account resolution behavior.

resolveAccountNamesByID built its map keyed only by CloudAccount.ID (UUID),
but PurchaseHistoryRecord.AccountID is the provider external ID (VARCHAR 20,
e.g. an AWS account number), not the UUID. The lookup always missed, so
AccountName was always empty and omitted from the JSON response, causing the
frontend to fall through to the ID-only display path.

Fix: also key the map by CloudAccount.ExternalID so the purchase-history
lookup path resolves the display name correctly. UUID callers (recommendation
records carrying cloud_account_id) continue to work via the UUID key.

Update TestHandler_listActiveCommitments_FiltersExpired and AccountFilter to
use realistic fixtures (ID=UUID, ExternalID=legacy account ID) so this
regression cannot hide behind matching test values again.
@cristim cristim added triaged Item has been triaged priority/p3 Polish / idea / may never ship severity/low Minor harm urgency/this-quarter Within the quarter impact/few Limited audience effort/xs Trivial / one-liner type/bug Defect labels Jun 4, 2026
@cristim
Copy link
Copy Markdown
Member Author

cristim commented Jun 4, 2026

@coderabbitai review

@cristim cristim added triaged Item has been triaged priority/p3 Polish / idea / may never ship severity/low Minor harm urgency/this-quarter Within the quarter impact/few Limited audience effort/xs Trivial / one-liner type/bug Defect labels Jun 4, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1d6324f3-cd43-4aaa-99af-5c92a69c9ea7

📥 Commits

Reviewing files that changed from the base of the PR and between f035285 and 045ab4e.

📒 Files selected for processing (2)
  • internal/api/handler_inventory_test.go
  • internal/api/scoping.go

📝 Walkthrough

Walkthrough

This PR fixes account name resolution in the commitments view. The production logic in scoping.go now dual-keys the account lookup map by both internal UUID and provider external ID. Test fixtures in handler_inventory_test.go are updated to align with this corrected resolution logic and explicitly validate name resolution via external ID.

Changes

Account name resolution fix

Layer / File(s) Summary
Dual-key account name resolution
internal/api/scoping.go
resolveAccountNamesByID builds a lookup map keyed by both internal CloudAccount.ID (UUID) and CloudAccount.ExternalID (provider external identifier), with map capacity increased for dual keys.
Test fixtures for account resolution
internal/api/handler_inventory_test.go
Inventory handler tests now mock CloudAccount records with UUID-like ID values and set ExternalID to provider identifiers; assertion message updated to require resolution via external ID.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

urgency/this-sprint

Poem

A curious rabbit finds the name,
not by UUID's obscure frame,
but by external ID's true claim—
the account now wears its proper name! 🐰

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the primary fix: enabling account name display in the Commitments view by resolving account names via ExternalID.
Linked Issues check ✅ Passed The PR successfully addresses issue #952 by dual-keying the nameByID map with both CloudAccount.ID and CloudAccount.ExternalID, enabling purchase-history lookups to resolve display names.
Out of Scope Changes check ✅ Passed All changes directly address the root cause in issue #952: map indexing and test fixture updates to support ExternalID-based lookups.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/952-commitments-account-name

Comment @coderabbitai help to get the list of available commands and usage tips.

@cristim
Copy link
Copy Markdown
Member Author

cristim commented Jun 4, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim
Copy link
Copy Markdown
Member Author

cristim commented Jun 4, 2026

@coderabbitai review

3 similar comments
@cristim
Copy link
Copy Markdown
Member Author

cristim commented Jun 4, 2026

@coderabbitai review

@cristim
Copy link
Copy Markdown
Member Author

cristim commented Jun 4, 2026

@coderabbitai review

@cristim
Copy link
Copy Markdown
Member Author

cristim commented Jun 4, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim
Copy link
Copy Markdown
Member Author

cristim commented Jun 4, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim
Copy link
Copy Markdown
Member Author

cristim commented Jun 4, 2026

@coderabbitai review

3 similar comments
@cristim
Copy link
Copy Markdown
Member Author

cristim commented Jun 4, 2026

@coderabbitai review

@cristim
Copy link
Copy Markdown
Member Author

cristim commented Jun 4, 2026

@coderabbitai review

@cristim
Copy link
Copy Markdown
Member Author

cristim commented Jun 4, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Rate Limit Exceeded

@cristim have exceeded the limit for the number of chat messages per hour. Please wait 48 minutes and 1 seconds before sending another message.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Rate Limit Exceeded

@cristim have exceeded the limit for the number of chat messages per hour. Please wait 48 minutes and 0 seconds before sending another message.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Rate Limit Exceeded

@cristim have exceeded the limit for the number of chat messages per hour. Please wait 47 minutes and 59 seconds before sending another message.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Rate Limit Exceeded

@cristim have exceeded the limit for the number of chat messages per hour. Please wait 47 minutes and 57 seconds before sending another message.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Rate Limit Exceeded

@cristim have exceeded the limit for the number of chat messages per hour. Please wait 47 minutes and 55 seconds before sending another message.

@cristim
Copy link
Copy Markdown
Member Author

cristim commented Jun 4, 2026

@coderabbitai review

4 similar comments
@cristim
Copy link
Copy Markdown
Member Author

cristim commented Jun 4, 2026

@coderabbitai review

@cristim
Copy link
Copy Markdown
Member Author

cristim commented Jun 4, 2026

@coderabbitai review

@cristim
Copy link
Copy Markdown
Member Author

cristim commented Jun 4, 2026

@coderabbitai review

@cristim
Copy link
Copy Markdown
Member Author

cristim commented Jun 4, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Rate Limit Exceeded

@cristim have exceeded the limit for the number of chat messages per hour. Please wait 47 minutes and 4 seconds before sending another message.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Rate Limit Exceeded

@cristim have exceeded the limit for the number of chat messages per hour. Please wait 47 minutes and 3 seconds before sending another message.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Rate Limit Exceeded

@cristim have exceeded the limit for the number of chat messages per hour. Please wait 47 minutes and 2 seconds before sending another message.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Rate Limit Exceeded

@cristim have exceeded the limit for the number of chat messages per hour. Please wait 47 minutes and 0 seconds before sending another message.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Rate Limit Exceeded

@cristim have exceeded the limit for the number of chat messages per hour. Please wait 46 minutes and 59 seconds before sending another message.

@cristim
Copy link
Copy Markdown
Member Author

cristim commented Jun 4, 2026

@coderabbitai review

3 similar comments
@cristim
Copy link
Copy Markdown
Member Author

cristim commented Jun 4, 2026

@coderabbitai review

@cristim
Copy link
Copy Markdown
Member Author

cristim commented Jun 4, 2026

@coderabbitai review

@cristim
Copy link
Copy Markdown
Member Author

cristim commented Jun 4, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Rate Limit Exceeded

@cristim have exceeded the limit for the number of chat messages per hour. Please wait 46 minutes and 6 seconds before sending another message.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Rate Limit Exceeded

@cristim have exceeded the limit for the number of chat messages per hour. Please wait 46 minutes and 4 seconds before sending another message.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Rate Limit Exceeded

@cristim have exceeded the limit for the number of chat messages per hour. Please wait 46 minutes and 1 seconds before sending another message.

@cristim cristim merged commit 83d5dc8 into feat/multicloud-web-frontend Jun 4, 2026
4 checks passed
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Rate Limit Exceeded

@cristim have exceeded the limit for the number of chat messages per hour. Please wait 44 minutes and 33 seconds before sending another message.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Rate Limit Exceeded

@cristim have exceeded the limit for the number of chat messages per hour. Please wait 25 minutes and 36 seconds before sending another message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/xs Trivial / one-liner impact/few Limited audience priority/p3 Polish / idea / may never ship severity/low Minor harm triaged Item has been triaged type/bug Defect urgency/this-quarter Within the quarter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant