Conversation
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
|
Thank you for following the naming conventions for pull request titles! 🙏 |
📝 WalkthroughWalkthroughAdds integration tests for API v2 root-key verification, updates Keys service to construct KeyVerifier inline (fixing nil-pointer when workspace is disabled), adds ForWorkspaceID to seed utilities to target keys to workspaces, and introduces a minor formatting change in status handling. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Client
participant API as API v2 (/v2/keys.verifyKey)
participant KeysSvc as Keys Service
participant DB
Client->>API: POST /v2/keys.verifyKey (Authorization: RootKey ...)
API->>KeysSvc: VerifyKey(request)
KeysSvc->>DB: Lookup key (+ForWorkspaceID) and workspace
DB-->>KeysSvc: Key, Workspace
alt Workspace disabled
note right of KeysSvc #D9EDF7: Construct KeyVerifier inline\n(with full context)
KeysSvc-->>API: 403 DisabledWorkspace
else Key missing / soft-deleted
KeysSvc-->>API: 401 Unauthorized
else Key disabled / expired
KeysSvc-->>API: 403 Forbidden
else Workspace not found
KeysSvc-->>API: 404 NotFound
else Insufficient permissions
KeysSvc-->>API: 403 Forbidden
else Valid
KeysSvc-->>API: 200 OK (+key data)
end
API-->>Client: HTTP response
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
💤 Files with no reviewable changes (1)
🧰 Additional context used🧬 Code graph analysis (1)go/internal/services/keys/get.go (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
🔇 Additional comments (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
go/apps/api/integration/root_keys/root_keys_test.go(1 hunks)go/internal/services/keys/get.go(2 hunks)go/internal/services/keys/status.go(1 hunks)go/pkg/testutil/seed/seed.go(2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-21T12:37:40.996Z
Learnt from: Flo4604
PR: unkeyed/unkey#3821
File: apps/dashboard/lib/trpc/routers/key/updateRootKeyPermissions.ts:74-74
Timestamp: 2025-08-21T12:37:40.996Z
Learning: Root keys in Unkey have two workspace fields: `workspaceId` (always set to env().UNKEY_WORKSPACE_ID for the Unkey workspace that owns the key) and `forWorkspaceId` (set to ctx.workspace.id for the user's workspace that the key is for). When querying root keys, the system filters by forWorkspaceId to get keys for the current user's workspace, but the returned rootKey.workspaceId is always the Unkey workspace ID.
Applied to files:
go/pkg/testutil/seed/seed.go
🧬 Code graph analysis (3)
go/pkg/testutil/seed/seed.go (2)
go/pkg/db/types/null_string.go (1)
NullString(10-10)go/pkg/ptr/deref.go (1)
SafeDeref(35-44)
go/apps/api/integration/root_keys/root_keys_test.go (5)
go/pkg/testutil/seed/seed.go (3)
Resources(23-28)CreateApiRequest(84-92)CreateKeyRequest(188-208)go/apps/api/integration/http.go (1)
CallRandomNode(104-111)go/pkg/db/key_update.sql_generated.go (1)
UpdateKeyParams(51-70)go/pkg/db/workspace_update_enabled.sql_generated.go (1)
UpdateWorkspaceEnabledParams(19-22)go/pkg/db/key_soft_delete_by_id.sql_generated.go (1)
SoftDeleteKeyByIDParams(17-20)
go/internal/services/keys/get.go (2)
go/internal/services/keys/verifier.go (1)
KeyVerifier(32-56)go/internal/services/keys/status.go (1)
StatusWorkspaceDisabled(23-23)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Test Go API Local / Test
- GitHub Check: Test API / API Test Local
- GitHub Check: Build / Build
|
I changed it, that we now log the workspace id of the disabled workspace. |
mcstepp
left a comment
There was a problem hiding this comment.
looks pretty solid and address the root issue, and there's test coverage. nothing major jumping out
Graphite Automations"Post a GIF when PR approved" took an action on this PR • (10/07/25)1 gif was posted to this PR based on Andreas Thomas's automation. |

What does this PR do?
Fixes #4082
When using an API key for a disabled workspace we shall not panic anymore, + adds tests for all root key statuses
Type of change
How should this be tested?
Create Root Key, in your local db set enabled to 0 for your workspace
Call any API you should get a nice error message saying the workspace is disabled.
Checklist
Required
pnpm buildpnpm fmtconsole.logsgit pull origin mainAppreciated