{"record":{"id":"34ff00466fa7b340","repo":"stablyai/orca","slug":"that-codex-rate-limit-account-no-longer-exists","errorCode":null,"errorMessage":"That Codex rate limit account no longer exists.","messagePattern":"That Codex rate limit account no longer exists\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/codex-accounts/service.ts","lineNumber":1105,"sourceCode":"    return {\n      id: account.id,\n      email: account.email,\n      managedHomeRuntime: account.managedHomeRuntime ?? 'host',\n      wslDistro: account.wslDistro ?? null,\n      providerAccountId: account.providerAccountId ?? null,\n      workspaceLabel: account.workspaceLabel ?? null,\n      workspaceAccountId: account.workspaceAccountId ?? null,\n      createdAt: account.createdAt,\n      updatedAt: account.updatedAt,\n      lastAuthenticatedAt: account.lastAuthenticatedAt\n    }\n  }\n\n  private requireAccount(accountId: string): CodexManagedAccount {\n    const settings = this.store.getSettings()\n    const account = settings.codexManagedAccounts.find((entry) => entry.id === accountId)\n    if (!account) {\n      throw new Error('That Codex rate limit account no longer exists.')\n    }\n    return account\n  }\n\n  private normalizeActiveSelection(): void {\n    const settings = this.store.getSettings()\n    const selection = normalizeCodexRuntimeSelection(settings)\n    const nextSelection = pruneInvalidCodexRuntimeSelection(\n      selection,\n      settings.codexManagedAccounts\n    )\n    const changed =\n      nextSelection.host !== selection.host ||\n      JSON.stringify(nextSelection.wsl) !== JSON.stringify(selection.wsl)\n    if (changed) {\n      this.store.updateSettings({\n        activeCodexManagedAccountId: nextSelection.host,\n        activeCodexManagedAccountIdsByRuntime: nextSelection","sourceCodeStart":1087,"sourceCodeEnd":1123,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/codex-accounts/service.ts#L1087-L1123","documentation":"Thrown by requireAccount, the single helper every account mutation uses to look up an account by ID. It scans settings.codexManagedAccounts and throws when no entry has the given id. Any operation on an account id that was removed (or never existed) hits this guard.","triggerScenarios":"Calling reauthenticateAccount / removeAccount / selectAccount / selectAccountForTarget (or getPendingResetAttemptForAccount indirectly) with an accountId that is not present in the current settings.codexManagedAccounts.","commonSituations":"Stale account id held by the UI (account removed in another window or by sync), a race where the user removed an account between rendering the list and acting on it, or a hard-coded/incorrect id passed by an integration.","solutions":["Refresh the account list (listAccounts) before acting and drop stale ids.","Guard the caller: check the id exists in listAccounts().accounts before invoking reauthenticate/remove/select.","Treat a missing id as already-removed and no-op at the UI layer rather than erroring."],"exampleFix":"// before: acting on an id that may be stale\nservice.removeAccount(accountId) // throws [913] if already gone\n\n// after: existence-check first\nconst exists = service.listAccounts().accounts.some(a => a.id === accountId)\nif (!exists) return { alreadyRemoved: true }\nawait service.removeAccount(accountId)","handlingStrategy":"validation","validationCode":"// Existence-check before any account mutation.\nconst exists = service.listAccounts().accounts.some(a => a.id === accountId)\nif (!exists) { return { status: 'not-found' } }\nawait service.reauthenticateAccount(accountId)","typeGuard":"const accountExists = (service: CodexAccountService, id: string): boolean =>\n  service.listAccounts().accounts.some(a => a.id === id)","tryCatchPattern":"try {\n  await service.removeAccount(accountId)\n} catch (error) {\n  if (error instanceof Error && error.message === 'That Codex rate limit account no longer exists.') {\n    // already removed — treat as success\n  } else throw error\n}","preventionTips":["Refresh listAccounts() before acting on an id from a stale render.","Treat removal-of-already-removed as a no-op at the caller."],"tags":["codex-accounts","not-found","stale-id","caller-error"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}