fix: resolve new repo creation with secrets created as global scope with current workspaceId#522
fix: resolve new repo creation with secrets created as global scope with current workspaceId#522nethi wants to merge 1 commit intojonwiggins:mainfrom
Conversation
…ith current workspaceId Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
jonwiggins
left a comment
There was a problem hiding this comment.
Thanks for chasing this down — the AAD/decryption diagnosis is right, and the AGENT_KEY_SECRETS additions are good.
Three asks before this is ready:
-
The fix isn't complete. Only 2 of the unscoped
retrieveSecretcall sites are patched here. A grep turns up several more that exhibit the same bug:apps/api/src/routes/issues.ts:197apps/api/src/routes/auth.ts:248apps/api/src/services/slack-service.ts:51apps/api/src/services/auth-service.ts:197apps/api/src/services/mcp-server-service.ts:141-182apps/api/src/services/connection-service.ts(multiple)apps/api/src/services/ticket-sync-service.ts:34apps/api/src/workers/token-validation-worker.ts:99
Could you do a single audit pass and thread
workspaceIdthrough everywhere, rather than patching piecemeal? -
Migration of legacy rows. Switching to a workspace-anchored AAD means pre-existing rows stored as
name|global|"global"won't decrypt with the new code. Could you switch the newretrieveSecretcalls toretrieveSecretWithFallback("NAME", "global", req.user?.workspaceId)so the secret-service's existing fallback logic handles legacy rows gracefully? -
Coordinate with #523. That PR fixes the read side of
/github-token/statusfor the same root bug. They're the same fix split across two PRs and should land together (or be combined). Up to you whether to consolidate or land #522 first then rebase #523.
Summary
Fixes new repository creation failures when secrets are created with global scope but include the current workspaceId. This resolves authentication and credential handling issues in multi-workspace environments.
Changes
Credential & Workspace Support
GEMINI_API_KEY,GOOGLE_CLOUD_PROJECT, andCLAUDE_VERTEX_PROJECT_IDtoAGENT_KEY_SECRETSfor setup completion detectionworkspaceIdtostoreSecret()in token rotation endpointworkspaceIdtoretrieveSecret()in repository validation logicTest Fixes
storeSecretexpectation to includeworkspaceIdparameter (4th argument)OPTIO_AUTH_DISABLED=truein Zod error sanitization tests to bypass authentication checksProblem
Secrets are now getting added with global scope and current workspaceId. However, several places in the new repo creation path were not passing current workspaceId. This broke:
Solution
Testing