{"record":{"id":"9d440bab080ec29d","repo":"koala73/worldmonitor","slug":"authentication-unavailable-while-loading-api-keys","errorCode":null,"errorMessage":"Authentication unavailable while loading API keys. Try again.","messagePattern":"Authentication unavailable while loading API keys\\. Try again\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/services/api-keys.ts","lineNumber":92,"sourceCode":"      (api as any).apiKeys.createApiKey,\n      { name: name.trim(), keyPrefix, keyHash },\n    ),\n  );\n  assertAccountStillCurrent(userId, 'creating the API key');\n\n  return { id: result.id, name: result.name, keyPrefix: result.keyPrefix, key: plaintext };\n}\n\n/** List all API keys for the current user. */\nexport async function listApiKeys(): Promise<ApiKeyInfo[]> {\n  const userId = getCurrentClerkUser()?.id;\n  if (!userId) return [];\n\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.');","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/koala73/worldmonitor/blob/eeab0a219fce0f02a00603b532dbae9041b934ac/src/services/api-keys.ts#L74-L110","documentation":"UI service error in listApiKeys: the current user is signed in, but Convex auth had not propagated for that user before the query ran. It is a session-propagation timing failure — the server cannot yet authorize the query for this account.","triggerScenarios":"Thrown at src/services/api-keys.ts:92 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry — Convex auth token propagation typically completes within moments","Reload the page if the error persists to force a fresh auth handshake"],"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-14T00:17:10.932Z"}