Skip to content

feat: add user_id filter to virtual keys list (enterprise-only, OSS fails closed) - #5653

Merged
akshaydeo merged 1 commit into
devfrom
07-29-feat_add_users_filter_on_vk_page
Jul 29, 2026
Merged

feat: add user_id filter to virtual keys list (enterprise-only, OSS fails closed)#5653
akshaydeo merged 1 commit into
devfrom
07-29-feat_add_users_filter_on_vk_page

Conversation

@impoiler

Copy link
Copy Markdown
Contributor

Summary

Adds a user_id query parameter to the virtual keys list endpoint, allowing callers to filter virtual keys by their assigned user. Because the virtual key–user relationship lives in an enterprise-only table, the OSS build fails closed (matches no keys) rather than silently returning unfiltered results. The enterprise store overrides the base implementation to honour the filter correctly.

Changes

  • Added user_id query parameter to the GET /virtual-keys OpenAPI spec, documented as enterprise-only and combined with customer_id/team_id using OR logic.
  • Refactored the assignment filter clause construction in GetVirtualKeysPaginated from a chain of if/else branches into a slice-based OR builder, making it straightforward to add the user_id clause. In the OSS build, a non-empty user_id injects 1 = 0 to ensure no rows are returned.
  • Added UserID to VirtualKeyQueryParams with a comment clarifying its OSS behaviour.
  • Wired user_id through the HTTP handler query arg parsing and into the params struct.
  • Added user_id URL state, filter prop threading, and a handleUserFilterChange callback in the virtual keys page.
  • Rendered the UserPicker component in the virtual keys table filter bar when a picker is registered (enterprise builds). The picker is hidden entirely in OSS builds where no picker is registered. An "or" label appears between the team/customer filters and the user filter when multiple assignment filters are active.
  • Extended UserPickerProps with placeholder, className, and triggerClassName to support use as a filter control.
  • Added user_id to GetVirtualKeysParams and the RTK Query API call.

Type of change

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

Affected areas

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

How to test

# Core/Transports
go test ./framework/configstore/... ./transports/bifrost-http/...

# UI
cd ui
pnpm i
pnpm build

OSS build — user_id filter fails closed:

GET /virtual-keys?user_id=some-user-id
# Expected: empty result set (0 keys returned), no error

Enterprise build — user_id filter returns matching keys:

GET /virtual-keys?user_id=<valid-user-id>
# Expected: only virtual keys assigned to that user are returned

GET /virtual-keys?user_id=<valid-user-id>&team_id=<valid-team-id>
# Expected: virtual keys assigned to that user OR belonging to that team

UI (enterprise build): Navigate to Governance → Virtual Keys. A user picker filter should appear in the filter bar. Selecting a user filters the table; clearing it restores the full list. The "or" label should appear between the team/customer filter and the user filter when both are active.

UI (OSS build): The user picker filter should not appear in the filter bar.

Breaking changes

  • Yes
  • No

Related issues

Security considerations

The OSS implementation explicitly returns no results when user_id is supplied, preventing any accidental data exposure from an unimplemented filter being silently ignored. The enterprise override is responsible for enforcing its own access control on the user-scoped query.

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

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ef76dfc4-9c8b-4548-8a6e-d15763ea6800

📥 Commits

Reviewing files that changed from the base of the PR and between b33deeb and 1d8cf3a.

📒 Files selected for processing (14)
  • docs/openapi/openapi.json
  • docs/openapi/paths/management/governance.yaml
  • framework/configstore/rdb.go
  • framework/configstore/rdb_test.go
  • framework/configstore/store.go
  • transports/bifrost-http/handlers/governance.go
  • transports/bifrost-http/handlers/governance_test.go
  • ui/app/workspace/dashboard/components/exportPopover.tsx
  • ui/app/workspace/governance/virtual-keys/page.tsx
  • ui/app/workspace/virtual-keys/views/virtualKeysTable.tsx
  • ui/components/entitySelectors/teamSelector.tsx
  • ui/lib/registries/userPicker.tsx
  • ui/lib/store/apis/governanceApi.ts
  • ui/lib/types/governance.ts
🚧 Files skipped from review as they are similar to previous changes (11)
  • ui/lib/types/governance.ts
  • framework/configstore/store.go
  • transports/bifrost-http/handlers/governance.go
  • ui/lib/registries/userPicker.tsx
  • docs/openapi/openapi.json
  • docs/openapi/paths/management/governance.yaml
  • ui/app/workspace/governance/virtual-keys/page.tsx
  • ui/components/entitySelectors/teamSelector.tsx
  • framework/configstore/rdb.go
  • transports/bifrost-http/handlers/governance_test.go
  • ui/app/workspace/virtual-keys/views/virtualKeysTable.tsx

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Added an optional user filter to the virtual keys list (enterprise-only; OSS returns no results), including URL-backed filtering and integration with pagination, navigation, and CSV export.
    • When combined with customer/team filters, results are combined as expected.
  • Bug Fixes
    • Requests using from_memory=true now reject user_id with a 400 instead of ignoring it.
  • Documentation
    • Updated API/OpenAPI docs for the new user_id parameter and explicit 400 error behavior.
  • Tests
    • Added coverage for from_memory/user_id validation and assignment-filter OR behavior.

Walkthrough

Virtual-key listing now supports an optional enterprise-only user_id filter across the API contract, backend query handling, URL state, and governance UI. OSS user filtering returns no matches, while from_memory requests with user_id return 400. Ranked endpoint documentation and export trigger styling are also updated.

Changes

Virtual-key user filtering

Layer / File(s) Summary
Filter contracts and picker props
docs/openapi/paths/management/governance.yaml, framework/configstore/store.go, ui/lib/types/governance.ts, ui/lib/registries/userPicker.tsx
Contracts document the enterprise-only user_id filter and its from_memory restriction; picker props add optional display and styling fields.
Backend filter propagation, application, and validation
transports/bifrost-http/handlers/governance.go, framework/configstore/rdb.go, framework/configstore/rdb_test.go, transports/bifrost-http/handlers/governance_test.go
The handler forwards user_id, rejects incompatible in-memory requests, and tests filter behavior; storage combines assignment predicates with OR and fails closed for OSS user filtering.
Governance UI filter integration
ui/app/workspace/governance/virtual-keys/page.tsx, ui/app/workspace/virtual-keys/views/virtualKeysTable.tsx, ui/lib/store/apis/governanceApi.ts, ui/components/entitySelectors/teamSelector.tsx
URL state, API requests, navigation, CSV export, filter summaries, and conditional user-picker controls include the user filter.

API and UI supporting updates

Layer / File(s) Summary
Generated endpoint parameter and response documentation
docs/openapi/openapi.json
The generated specification documents virtual-key filtering and 400 behavior, and adds limit and all controls to two ranked endpoint definitions.
Export submenu trigger styling
ui/app/workspace/dashboard/components/exportPopover.tsx
CSV and PDF submenu triggers receive flex layout and spacing classes without behavior changes.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested reviewers: akshaydeo, tejasghatte, pratham-mishra04

Sequence Diagram(s)

sequenceDiagram
  participant Page as GovernanceVirtualKeysPage
  participant Table as VirtualKeysTable
  participant API as governanceApi.getVirtualKeys
  participant Handler as getVirtualKeys
  participant Store as GetVirtualKeysPaginated
  Page->>Table: pass userFilter
  Table->>API: request user_id
  API->>Handler: send user_id
  Handler->>Store: pass UserID
  Store-->>Handler: return filtered virtual keys
  Handler-->>API: return response
  API-->>Table: render results
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change and is specific about the enterprise-only user_id filter and OSS fail-closed behavior.
Description check ✅ Passed The description covers the required template sections and gives a clear summary, changes, testing, and security notes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 07-29-feat_add_users_filter_on_vk_page

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


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

Copy link
Copy Markdown
Contributor Author

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

@impoiler impoiler self-assigned this Jul 29, 2026
@impoiler
impoiler marked this pull request as ready for review July 29, 2026 10:53

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@framework/configstore/rdb.go`:
- Around line 3275-3294: The assignment filtering flow should fail closed
immediately for OSS UserID queries. In the method containing the
assignmentClauses construction, return an empty result set before adding
customer or team clauses whenever params.UserID is set; remove the 1 = 0 clause,
and add table-driven tests covering user-only and user-plus-customer/team
combinations.

In `@transports/bifrost-http/handlers/governance.go`:
- Around line 1193-1207: Update the virtual-key GET handler so userID is honored
when from_memory=true instead of bypassed by the in-memory early return. Apply
the user_id filter to the cached-key path, or explicitly reject the combination
with a documented 400 response; preserve existing behavior for other query
modes.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: afd1af34-d45c-4abc-89ec-7d733753e435

📥 Commits

Reviewing files that changed from the base of the PR and between d307e8a and 594f22e.

📒 Files selected for processing (9)
  • docs/openapi/paths/management/governance.yaml
  • framework/configstore/rdb.go
  • framework/configstore/store.go
  • transports/bifrost-http/handlers/governance.go
  • ui/app/workspace/governance/virtual-keys/page.tsx
  • ui/app/workspace/virtual-keys/views/virtualKeysTable.tsx
  • ui/lib/registries/userPicker.tsx
  • ui/lib/store/apis/governanceApi.ts
  • ui/lib/types/governance.ts

Comment thread framework/configstore/rdb.go
Comment thread transports/bifrost-http/handlers/governance.go
@impoiler
impoiler force-pushed the 07-29-feat_add_users_filter_on_vk_page branch 2 times, most recently from 6d732fb to b33deeb Compare July 29, 2026 11:05
@coderabbitai
coderabbitai Bot requested a review from TejasGhatte July 29, 2026 11:06
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 29, 2026
@impoiler
impoiler force-pushed the 07-29-feat_add_users_filter_on_vk_page branch from b33deeb to 1d8cf3a Compare July 29, 2026 11:10

akshaydeo commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Merge activity

  • Jul 29, 11:12 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jul 29, 11:13 AM UTC: @akshaydeo merged this pull request with Graphite.

@akshaydeo
akshaydeo merged commit 95e948f into dev Jul 29, 2026
13 of 14 checks passed
@akshaydeo
akshaydeo deleted the 07-29-feat_add_users_filter_on_vk_page branch July 29, 2026 11:13
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