{"record":{"id":"82680d1acdf6bc5e","repo":"koala73/worldmonitor","slug":"sign-in-to-revoke-api-keys","errorCode":null,"errorMessage":"Sign in to revoke API keys.","messagePattern":"Sign in to revoke API keys\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/services/api-keys.ts","lineNumber":105,"sourceCode":"\n  const [client, api] = await Promise.all([getConvexClient(), getConvexApi()]);\n  if (!client || !api) return [];\n  if (!await waitForConvexAuthForUser(userId)) {\n    assertAccountStillCurrent(userId, 'loading API keys');\n    throw new Error('Authentication unavailable while loading API keys. Try again.');\n  }\n\n  return settleAccountOperation(\n    userId,\n    'loading API keys',\n    () => client.query((api as any).apiKeys.listApiKeys, {}),\n  );\n}\n\n/** Revoke an API key by its Convex document ID. */\nexport async function revokeApiKey(keyId: string): Promise<void> {\n  const userId = getCurrentClerkUser()?.id;\n  if (!userId) throw new Error('Sign in to revoke API keys.');\n\n  const [client, api] = await Promise.all([getConvexClient(), getConvexApi()]);\n  if (!client || !api) throw new Error('Convex unavailable');\n  if (!await waitForConvexAuthForUser(userId)) {\n    throw new Error('Account changed while revoking the API key. Try again.');\n  }\n\n  const result = await settleAccountOperation(\n    userId,\n    'revoking the API key',\n    () => client.mutation((api as any).apiKeys.revokeApiKey, { keyId }),\n  );\n  assertAccountStillCurrent(userId, 'revoking the API key');\n\n  // Await cache bust so the gateway stops accepting the revoked key immediately.\n  // If this fails, the 60s cache TTL limits the staleness window.\n  if (result?.keyHash) {\n    const token = await settleAccountOperation(","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/koala73/worldmonitor/blob/eeab0a219fce0f02a00603b532dbae9041b934ac/src/services/api-keys.ts#L87-L123","documentation":"UI service error in revokeApiKey: no Clerk user is currently authenticated. Revocation requires knowing whose key is being revoked; the guard fires before any Convex call.","triggerScenarios":"Thrown at src/services/api-keys.ts:105 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Sign in and retry the revocation","Wait for the Clerk session to finish loading if sign-in just happened"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"eeab0a219fce0f02a00603b532dbae9041b934ac","analyzedAt":"2026-08-21T16:51:25.751Z","contentChangedAt":"2026-08-21T16:51:25.751Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}