Skip to content

feat: assign virtual keys on teams page directly#2757

Merged
akshaydeo merged 1 commit intov1.5.0from
04-16-feat_assign_virtual_keys_on_teams_page_directly
Apr 17, 2026
Merged

feat: assign virtual keys on teams page directly#2757
akshaydeo merged 1 commit intov1.5.0from
04-16-feat_assign_virtual_keys_on_teams_page_directly

Conversation

@BearTS
Copy link
Copy Markdown
Contributor

@BearTS BearTS commented Apr 16, 2026

Summary

Adds a virtual key count field to team queries to display the number of virtual keys associated with each team without requiring additional database queries or loading the full virtual keys collection.

Changes

  • Added VirtualKeyCount field to TableTeam struct as a computed field populated via correlated subquery
  • Modified GetTeams, GetTeamsPaginated, and GetTeam methods to include virtual key count in SELECT queries
  • Updated TypeScript types to allow nullable team_id and customer_id in UpdateVirtualKeyRequest
  • Changed VirtualKeys field in team table to be omitempty for cleaner JSON responses

Type of change

  • Feature
  • Bug fix
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs

How to test

Verify that team queries return the virtual key count and that virtual key updates handle nullable team/customer IDs:

# Core/Transports
go version
go test ./...

# UI
cd ui
pnpm i || npm i
pnpm test || npm test
pnpm build || npm run build

Test API endpoints that retrieve teams to ensure virtual_key_count field is populated correctly.

Screenshots/Recordings

N/A

Breaking changes

  • Yes
  • No

Related issues

N/A

Security considerations

The correlated subquery only counts records and doesn't expose sensitive virtual key data. No additional security implications.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 16, 2026

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Team objects now include a virtual_key_count field.
  • Improvements

    • virtual_keys may be omitted or returned as null in certain API responses to avoid recursive nesting.
    • OpenAPI spec updated to document virtual_key_count and add a Google API key auth scheme.
  • Bug Fixes

    • Governance responses now reliably reflect recomputed virtual key counts when assembling team/customer data.

Walkthrough

Team queries now include a correlated subquery providing virtual_key_count; TableTeam adds VirtualKeyCount and makes virtual_keys omittable/nullable; OpenAPI schemas and a Google API key scheme were updated; governance snapshot logic now computes VirtualKeyCount from virtual keys before wiring teams into customers.

Changes

Cohort / File(s) Summary
Config store: query + model
framework/configstore/rdb.go, framework/configstore/tables/team.go
Added a package-level select fragment that projects a correlated subquery as virtual_key_count in team queries; added VirtualKeyCount int64 (GORM read-only/computed) to TableTeam; made virtual_keys JSON omitempty/nullable.
Governance plugin store
plugins/governance/store.go
Reordered snapshot construction: reset cloned teams' VirtualKeyCount, iterate virtual-keys to increment matching teams' VirtualKeyCount, then wire teams into customers so counts are reflected in the final snapshot.
API spec (OpenAPI & schemas)
docs/openapi/openapi.json, docs/openapi/schemas/management/governance.yaml, docs/openapi/schemas/management/users.yaml
Added virtual_key_count integer to Team schemas; marked virtual_keys nullable and clarified omission behavior; added GoogleApiKeyAuth security scheme using the x-goog-api-key header.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant API as API Server
    participant Store as ConfigStore (GORM)
    participant DB as Database
    participant Plugin as GovernancePlugin

    Client->>API: Request teams / governance
    API->>Store: Query teams (Select includes correlated COUNT of virtual_keys)
    Store->>DB: SELECT teams + correlated subquery AS virtual_key_count
    DB-->>Store: Rows with virtual_key_count
    Store-->>API: Teams (preloaded relations, virtual_key_count)
    API->>Plugin: Build governance snapshot (teams, virtualKeys, customers)
    Plugin->>Plugin: reset team.VirtualKeyCount = 0
    Plugin->>Plugin: iterate virtualKeys -> increment matching team.VirtualKeyCount
    Plugin->>Plugin: wire teams into customers (now with updated counts)
    Plugin-->>API: governance data (teams with virtual_key_count)
    API-->>Client: Response
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

"I hopped through rows and counted keys,
I nudged each team with gentle ease,
From zero marks to totals bright,
I set their counts and set them right.
🐇✨"

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title describes a feature to assign virtual keys on teams page, but the actual changeset focuses on adding a virtual key count field and related database optimizations. Update the title to reflect the main change: 'feat: add virtual key count field to team queries' or similar, as the PR does not implement direct assignment of virtual keys on the teams page.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The description covers most required sections including summary, changes, type, affected areas, testing, breaking changes, and security considerations. However, checklist items for tests, documentation, and CI verification are marked incomplete.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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 04-16-feat_assign_virtual_keys_on_teams_page_directly

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

Copy link
Copy Markdown
Contributor Author

BearTS commented Apr 16, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@BearTS BearTS marked this pull request as ready for review April 16, 2026 09:25
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 16, 2026

Confidence Score: 5/5

Safe to merge; the only finding is a documentation gap in the governance schema, not a runtime defect.

All code changes (GORM tag, correlated subquery, in-memory store reset/recompute) are correct. The sole issue is that governance.yaml#Team and the compiled openapi.json Team component are missing virtual_key_count, while the actual API responses include it. This is a P2 schema gap, not a functional bug.

docs/openapi/schemas/management/governance.yaml and docs/openapi/openapi.json — the canonical Team schema needs the virtual_key_count field added.

Important Files Changed

Filename Overview
framework/configstore/tables/team.go Adds VirtualKeyCount int64 computed field with gorm:"->;-:migration" and json:"virtual_key_count". Tag is correct: GORM scans the value from SELECT results but never writes it or migrates a column for it.
framework/configstore/rdb.go Introduces teamSelectWithVKCount correlated subquery constant and applies it to GetTeams, GetTeamsPaginated, and GetTeam. The count query in GetTeamsPaginated runs before the Select override, so it is unaffected. Logic is sound.
plugins/governance/store.go In-memory GetAllData resets VirtualKeyCount to 0 on each team clone before recomputing from live VKs, preventing stale counts after VK create/update/delete without a full reload. Logic is correct.
docs/openapi/schemas/management/governance.yaml The Team schema is missing the new virtual_key_count field, creating a documentation gap for governance API consumers, though users.yaml#TeamObject was correctly updated.
docs/openapi/schemas/management/users.yaml Correctly adds virtual_key_count to TeamObject schema used by user/SCIM team endpoints.
docs/openapi/openapi.json Compiled spec includes virtual_key_count in the inlined TeamObject response schemas but the canonical Team component schema (used by governance endpoints) is missing the field.

Reviews (6): Last reviewed commit: "feat: assign virtual keys on teams page ..." | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@framework/configstore/rdb.go`:
- Around line 2525-2527: The in-memory snapshot returned by
governanceManager.GetGovernanceData() / GetGovernanceConfig still leaves
Team.VirtualKeyCount at 0 because teams are loaded with a plain Find(&teams);
update the snapshot build to populate VirtualKeyCount by running the same
subquery used in the DB path (SELECT COUNT(*) FROM governance_virtual_keys WHERE
team_id = governance_teams.id) or an equivalent aggregate query and assign the
result into each Team.VirtualKeyCount, referencing the Team struct field
VirtualKeyCount and the governance_virtual_keys table; alternatively, if you
prefer not to compute counts for in-memory snapshots, ensure the handlers omit
or nil out the VirtualKeyCount field when it was not computed so both paths
return consistent responses.

In `@ui/lib/types/governance.ts`:
- Around line 177-178: The TypeScript fields team_id and customer_id currently
allow null (team_id?: string | null; customer_id?: string | null), but sending
null will be indistinguishable from omitted on the Go side (the handler checks
if req.TeamID != nil), so change both fields to optional non-nullable strings
(team_id?: string; customer_id?: string;) so clients omit the field to leave
associations unchanged; if you need an explicit "clear" operation instead, add a
separate boolean flag or explicit clear token in the contract and update the
corresponding request types and client code to use that signal.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a08dcbce-5e4d-47fd-8210-35938771417e

📥 Commits

Reviewing files that changed from the base of the PR and between d56fa10 and f80256a.

📒 Files selected for processing (3)
  • framework/configstore/rdb.go
  • framework/configstore/tables/team.go
  • ui/lib/types/governance.ts

Comment thread framework/configstore/rdb.go
Comment thread ui/lib/types/governance.ts Outdated
@BearTS BearTS force-pushed the 04-16-feat_assign_virtual_keys_on_teams_page_directly branch from f80256a to 4d4b7f8 Compare April 16, 2026 10:14
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/openapi/schemas/management/governance.yaml (1)

361-438: ⚠️ Potential issue | 🟠 Major

Add virtual_key_count to Team schema to match runtime responses.

Team responses now include a computed virtual_key_count, but this schema still omits that property. This causes API contract drift for docs/codegen/validation.

📘 Proposed schema patch
 Team:
   type: object
   description: Team configuration
   properties:
@@
     virtual_keys:
       type: array
       nullable: true
       description: >
         Virtual keys assigned to this team. This field may be omitted or returned as null in some
         responses (for example, when a team is embedded inside a virtual-key response) to avoid
         nested `virtual_keys` recursion.
       items:
         $ref: '#/VirtualKey'
+    virtual_key_count:
+      type: integer
+      format: int64
+      description: Number of virtual keys assigned to this team.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/openapi/schemas/management/governance.yaml` around lines 361 - 438, The
Team schema is missing the runtime-only computed property virtual_key_count;
update the Team object definition to include a new property named
virtual_key_count (type: integer, nullable: true or integer according to runtime
behavior) alongside virtual_keys so API docs/codegen/validation match responses,
and ensure CreateTeamRequest/UpdateTeamRequest/ListTeamsResponse need no
changes; modify the Team schema block (properties: ...) to add virtual_key_count
with an appropriate description like "Computed number of virtual keys for this
team".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@docs/openapi/schemas/management/governance.yaml`:
- Around line 361-438: The Team schema is missing the runtime-only computed
property virtual_key_count; update the Team object definition to include a new
property named virtual_key_count (type: integer, nullable: true or integer
according to runtime behavior) alongside virtual_keys so API
docs/codegen/validation match responses, and ensure
CreateTeamRequest/UpdateTeamRequest/ListTeamsResponse need no changes; modify
the Team schema block (properties: ...) to add virtual_key_count with an
appropriate description like "Computed number of virtual keys for this team".

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0c13f59f-471d-4d0b-bab0-b7e5ba8fd336

📥 Commits

Reviewing files that changed from the base of the PR and between f80256a and 4d4b7f8.

📒 Files selected for processing (6)
  • docs/openapi/openapi.json
  • docs/openapi/schemas/management/governance.yaml
  • docs/openapi/schemas/management/users.yaml
  • framework/configstore/rdb.go
  • framework/configstore/tables/team.go
  • ui/lib/types/governance.ts
✅ Files skipped from review due to trivial changes (1)
  • docs/openapi/schemas/management/users.yaml
🚧 Files skipped from review as they are similar to previous changes (2)
  • ui/lib/types/governance.ts
  • framework/configstore/rdb.go

@BearTS BearTS force-pushed the 04-16-feat_assign_virtual_keys_on_teams_page_directly branch from 4d4b7f8 to c5f134d Compare April 16, 2026 10:37
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
framework/configstore/rdb.go (1)

2525-2527: Extract the virtual_key_count projection into a shared team-query scope.

The same Select("governance_teams.*, (SELECT COUNT(*) ...) AS virtual_key_count") now exists in four places. Keeping that SQL inline everywhere makes it easy for one path to drift again the next time team loading changes.

♻️ Suggested cleanup
+func withTeamVirtualKeyCount(db *gorm.DB) *gorm.DB {
+	return db.Select(`
+		governance_teams.*,
+		(SELECT COUNT(*) FROM governance_virtual_keys WHERE team_id = governance_teams.id) AS virtual_key_count
+	`)
+}
+
 func (s *RDBConfigStore) GetTeams(ctx context.Context, customerID string) ([]tables.TableTeam, error) {
-	query := s.db.WithContext(ctx).
-		Select("governance_teams.*, (SELECT COUNT(*) FROM governance_virtual_keys WHERE team_id = governance_teams.id) AS virtual_key_count").
+	query := withTeamVirtualKeyCount(s.db.WithContext(ctx)).
 		Preload("Customer").Preload("Budget").Preload("RateLimit")
-	if err := baseQuery.
-		Select("governance_teams.*, (SELECT COUNT(*) FROM governance_virtual_keys WHERE team_id = governance_teams.id) AS virtual_key_count").
+	if err := withTeamVirtualKeyCount(baseQuery).
 		Preload("Customer").Preload("Budget").Preload("RateLimit").
-	if err := s.db.WithContext(ctx).
-		Select("governance_teams.*, (SELECT COUNT(*) FROM governance_virtual_keys WHERE team_id = governance_teams.id) AS virtual_key_count").
+	if err := withTeamVirtualKeyCount(s.db.WithContext(ctx)).
 		Preload("Customer").Preload("Budget").Preload("RateLimit").
-	if err := s.db.WithContext(ctx).
-		Select("governance_teams.*, (SELECT COUNT(*) FROM governance_virtual_keys WHERE team_id = governance_teams.id) AS virtual_key_count").
+	if err := withTeamVirtualKeyCount(s.db.WithContext(ctx)).
 		Find(&teams).Error; err != nil {

As per coding guidelines, "**: always check the stack if there is one for the current PR. do not give localized reviews for the PR, always see all changes in the light of the whole stack of PRs (if there is a stack, if there is no stack you can continue to make localized suggestions/reviews)".

Also applies to: 2569-2570, 2583-2586, 3434-3436

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@framework/configstore/rdb.go` around lines 2525 - 2527, Extract the repeated
Select projection "(SELECT COUNT(*) FROM governance_virtual_keys WHERE team_id =
governance_teams.id) AS virtual_key_count" into a reusable GORM scope (e.g.,
WithVirtualKeyCount or TeamWithVirtualKeyCount) and replace the inline Select in
every place where query := s.db.WithContext(ctx).Select("governance_teams.*,
(SELECT COUNT(*) ... ) AS virtual_key_count") is used (including the other
occurrences noted). Implement the scope so it returns a func(*gorm.DB) *gorm.DB
that applies Select("governance_teams.*, (SELECT COUNT(*) ... ) AS
virtual_key_count"), and update callers (the variables named query and any
usages of Preload("Customer").Preload("Budget").Preload("RateLimit")) to call
.Scopes(WithVirtualKeyCount) instead of duplicating the SQL.
plugins/governance/store.go (1)

286-355: Add a focused regression test for count/wiring order.

Please add a unit/integration test that asserts GetGovernanceData() returns identical VirtualKeyCount for both Teams[id] and the corresponding customer.Teams[] entry after VK create/update/delete flows. This will lock in the ordering contract introduced here.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/governance/store.go` around lines 286 - 355, Add a regression test
that exercises VK create/update/delete flows and then calls GetGovernanceData(),
asserting that the VirtualKeyCount on the top-level teams map (teams[id]) equals
the VirtualKeyCount on the corresponding team object embedded inside its
customer (customer.Teams[]). Locate the call path that populates teams/customers
and wires VirtualKeyCount (the loop over virtualKeys and the subsequent
teams→customers wiring in GetGovernanceData or equivalent method), simulate VK
changes, invoke GetGovernanceData(), and assert equality for each matching team
id to lock in the ordering contract.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/openapi/openapi.json`:
- Around line 33457-33467: The OpenAPI spec is missing a security scheme for the
x-goog-api-key header used by the /api/governance/virtual-keys/quota handler;
add a GoogleApiKeyAuth (or GoogleApiKey) security scheme defining an apiKey in:
header with name: x-goog-api-key under components.securitySchemes (or
securityDefinitions if this spec is v2), and then include a reference to that
scheme (e.g., "GoogleApiKeyAuth": []) in the quota operation's "security" array
alongside VirtualKeyAuth/BearerAuth/ApiKeyAuth so clients and docs reflect the
handler's accepted auth.

---

Nitpick comments:
In `@framework/configstore/rdb.go`:
- Around line 2525-2527: Extract the repeated Select projection "(SELECT
COUNT(*) FROM governance_virtual_keys WHERE team_id = governance_teams.id) AS
virtual_key_count" into a reusable GORM scope (e.g., WithVirtualKeyCount or
TeamWithVirtualKeyCount) and replace the inline Select in every place where
query := s.db.WithContext(ctx).Select("governance_teams.*, (SELECT COUNT(*) ...
) AS virtual_key_count") is used (including the other occurrences noted).
Implement the scope so it returns a func(*gorm.DB) *gorm.DB that applies
Select("governance_teams.*, (SELECT COUNT(*) ... ) AS virtual_key_count"), and
update callers (the variables named query and any usages of
Preload("Customer").Preload("Budget").Preload("RateLimit")) to call
.Scopes(WithVirtualKeyCount) instead of duplicating the SQL.

In `@plugins/governance/store.go`:
- Around line 286-355: Add a regression test that exercises VK
create/update/delete flows and then calls GetGovernanceData(), asserting that
the VirtualKeyCount on the top-level teams map (teams[id]) equals the
VirtualKeyCount on the corresponding team object embedded inside its customer
(customer.Teams[]). Locate the call path that populates teams/customers and
wires VirtualKeyCount (the loop over virtualKeys and the subsequent
teams→customers wiring in GetGovernanceData or equivalent method), simulate VK
changes, invoke GetGovernanceData(), and assert equality for each matching team
id to lock in the ordering contract.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e1e40c1e-96e3-49ef-983e-c6e2e61dbf81

📥 Commits

Reviewing files that changed from the base of the PR and between 4d4b7f8 and c5f134d.

📒 Files selected for processing (6)
  • docs/openapi/openapi.json
  • docs/openapi/schemas/management/governance.yaml
  • docs/openapi/schemas/management/users.yaml
  • framework/configstore/rdb.go
  • framework/configstore/tables/team.go
  • plugins/governance/store.go
✅ Files skipped from review due to trivial changes (1)
  • docs/openapi/schemas/management/users.yaml
🚧 Files skipped from review as they are similar to previous changes (2)
  • docs/openapi/schemas/management/governance.yaml
  • framework/configstore/tables/team.go

Comment thread docs/openapi/openapi.json Outdated
@BearTS BearTS force-pushed the 04-16-feat_assign_virtual_keys_on_teams_page_directly branch from c5f134d to 924e214 Compare April 16, 2026 11:17
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
framework/configstore/rdb.go (1)

4502-4502: Minor: Consider extracting the repeated SELECT clause.

The correlated subquery for virtual_key_count is duplicated across 4 methods (GetTeams, GetTeamsPaginated, GetTeam, GetGovernanceConfig). Consider extracting it to a constant:

const teamSelectWithVKCount = "governance_teams.*, (SELECT COUNT(*) FROM governance_virtual_keys WHERE team_id = governance_teams.id) AS virtual_key_count"

This is optional - the current approach works correctly and the duplication is manageable.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@framework/configstore/rdb.go` at line 4502, Extract the duplicated SELECT
clause used to compute virtual_key_count into a single constant (e.g.,
teamSelectWithVKCount) and replace the repeated string in GetTeams,
GetTeamsPaginated, GetTeam, and GetGovernanceConfig with that constant; ensure
the constant value is exactly "governance_teams.*, (SELECT COUNT(*) FROM
governance_virtual_keys WHERE team_id = governance_teams.id) AS
virtual_key_count" and update each query-building site to reference
teamSelectWithVKCount so behavior remains identical.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/openapi/openapi.json`:
- Around line 51646-51668: The OpenAPI schema removed the request field
enable_litellm_fallbacks without a deprecation path; either restore it as a
deprecated property on the request schemas or explicitly bump the API version
and document the breaking change. Update the request schema definitions to
include "enable_litellm_fallbacks": { "type": "boolean", "deprecated": true,
"description": "Deprecated: use compat.convert_text_to_chat" } so existing
clients validate for one release, or alternatively add an API-version bump and
release note; ensure this change aligns with the DB migration function
migrationReplaceEnableLiteLLMWithCompatColumns and mirror the same decision for
the other affected schema instances (around the second range noted).

---

Nitpick comments:
In `@framework/configstore/rdb.go`:
- Line 4502: Extract the duplicated SELECT clause used to compute
virtual_key_count into a single constant (e.g., teamSelectWithVKCount) and
replace the repeated string in GetTeams, GetTeamsPaginated, GetTeam, and
GetGovernanceConfig with that constant; ensure the constant value is exactly
"governance_teams.*, (SELECT COUNT(*) FROM governance_virtual_keys WHERE team_id
= governance_teams.id) AS virtual_key_count" and update each query-building site
to reference teamSelectWithVKCount so behavior remains identical.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 207732d7-ecab-4999-88d4-1e1abbfc6747

📥 Commits

Reviewing files that changed from the base of the PR and between c5f134d and 924e214.

📒 Files selected for processing (6)
  • docs/openapi/openapi.json
  • docs/openapi/schemas/management/governance.yaml
  • docs/openapi/schemas/management/users.yaml
  • framework/configstore/rdb.go
  • framework/configstore/tables/team.go
  • plugins/governance/store.go
✅ Files skipped from review due to trivial changes (1)
  • docs/openapi/schemas/management/users.yaml
🚧 Files skipped from review as they are similar to previous changes (2)
  • docs/openapi/schemas/management/governance.yaml
  • framework/configstore/tables/team.go

Comment thread docs/openapi/openapi.json Outdated
@BearTS BearTS force-pushed the 04-16-feat_assign_virtual_keys_on_teams_page_directly branch from 924e214 to bcc3d05 Compare April 16, 2026 11:39
coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 16, 2026
@BearTS BearTS force-pushed the 04-16-feat_assign_virtual_keys_on_teams_page_directly branch from bcc3d05 to 5900a79 Compare April 16, 2026 11:45
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/openapi/openapi.json`:
- Around line 41537-41541: The OpenAPI spec defines the GoogleApiKeyAuth
security scheme but never references it; update the operation objects that
should accept Google API keys (e.g., the /api/governance/virtual-keys/quota path
and any other relevant operations) to include GoogleApiKeyAuth in their security
arrays by adding an entry like {"GoogleApiKeyAuth": []} to each operation's
security array (or create a security array if missing), ensuring the
operation-level security lists both existing schemes (if any) and
GoogleApiKeyAuth so clients can discover and use the x-goog-api-key header.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0fadeafe-9447-4e36-ac24-68b7aa15b911

📥 Commits

Reviewing files that changed from the base of the PR and between bcc3d05 and 5900a79.

📒 Files selected for processing (6)
  • docs/openapi/openapi.json
  • docs/openapi/schemas/management/governance.yaml
  • docs/openapi/schemas/management/users.yaml
  • framework/configstore/rdb.go
  • framework/configstore/tables/team.go
  • plugins/governance/store.go
✅ Files skipped from review due to trivial changes (2)
  • docs/openapi/schemas/management/users.yaml
  • plugins/governance/store.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • docs/openapi/schemas/management/governance.yaml
  • framework/configstore/tables/team.go

Comment thread docs/openapi/openapi.json
@BearTS BearTS force-pushed the 04-16-feat_assign_virtual_keys_on_teams_page_directly branch from 5900a79 to ea7a2d2 Compare April 16, 2026 11:54
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
framework/configstore/rdb.go (1)

2522-2522: Please add one regression test for every team read path.

This field now depends on the same projection being present in four separate queries. A small integration test covering list, paginated list, single-team, and GetGovernanceConfig would make future drift much harder.

Also applies to: 2527-2529, 2571-2571, 2585-2588, 3436-3438

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@framework/configstore/rdb.go` at line 2522, Add regression tests that assert
the virtual_key_count projection introduced by teamSelectWithVKCount is present
and correct across every team read path: the teams list (e.g., ListTeams), the
paginated list (e.g., ListTeamsPaginated or equivalent), the single-team getter
(e.g., GetTeamByID/GetTeam), and GetGovernanceConfig. For each test, seed a
known set of governance_virtual_keys linked to a team, call the corresponding
method, and assert the returned record(s) include virtual_key_count with the
expected numeric value; include at least one test for empty/zero count and one
for >0 to catch projection drift.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@framework/configstore/rdb.go`:
- Line 2522: Add regression tests that assert the virtual_key_count projection
introduced by teamSelectWithVKCount is present and correct across every team
read path: the teams list (e.g., ListTeams), the paginated list (e.g.,
ListTeamsPaginated or equivalent), the single-team getter (e.g.,
GetTeamByID/GetTeam), and GetGovernanceConfig. For each test, seed a known set
of governance_virtual_keys linked to a team, call the corresponding method, and
assert the returned record(s) include virtual_key_count with the expected
numeric value; include at least one test for empty/zero count and one for >0 to
catch projection drift.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a357f8c7-115c-420b-9d45-f9b86f132e8d

📥 Commits

Reviewing files that changed from the base of the PR and between 5900a79 and ea7a2d2.

📒 Files selected for processing (6)
  • docs/openapi/openapi.json
  • docs/openapi/schemas/management/governance.yaml
  • docs/openapi/schemas/management/users.yaml
  • framework/configstore/rdb.go
  • framework/configstore/tables/team.go
  • plugins/governance/store.go
✅ Files skipped from review due to trivial changes (2)
  • docs/openapi/schemas/management/users.yaml
  • plugins/governance/store.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • framework/configstore/tables/team.go
  • docs/openapi/schemas/management/governance.yaml
  • docs/openapi/openapi.json

Copy link
Copy Markdown
Contributor

akshaydeo commented Apr 17, 2026

Merge activity

  • Apr 17, 10:52 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Apr 17, 10:53 AM UTC: @akshaydeo merged this pull request with Graphite.

@akshaydeo akshaydeo merged commit c75a802 into v1.5.0 Apr 17, 2026
18 of 20 checks passed
@akshaydeo akshaydeo deleted the 04-16-feat_assign_virtual_keys_on_teams_page_directly branch April 17, 2026 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants