{"record":{"id":"d4b1c4742162824f","repo":"stablyai/orca","slug":"this-claude-account-is-already-added","errorCode":null,"errorMessage":"This Claude account is already added.","messagePattern":"This Claude account is already added\\.","errorType":"exception","errorClass":"DuplicateClaudeAccountError","httpStatus":null,"severity":"warning","filePath":"src/main/claude-accounts/service.ts","lineNumber":267,"sourceCode":"    accountId: string,\n    managedAuth: ManagedClaudeAuthLocation,\n    previousSettings: ReturnType<Store['getSettings']>,\n    captured: CapturedClaudeAuth\n  ): Promise<ClaudeRateLimitAccountsState> {\n    if (!captured.identity.email) {\n      throw new Error('Claude login completed, but Orca could not resolve the account email.')\n    }\n    // Why: duplicate rows confuse selection and rate-limit tracking; re-authentication\n    // is the supported way to refresh an account that is already managed.\n    if (\n      findDuplicateClaudeAccount(previousSettings.claudeManagedAccounts, {\n        email: captured.identity.email,\n        organizationUuid: captured.identity.organizationUuid,\n        managedAuthRuntime: managedAuth.managedAuthRuntime,\n        wslDistro: managedAuth.wslDistro\n      })\n    ) {\n      throw new DuplicateClaudeAccountError('This Claude account is already added.')\n    }\n    await this.writeManagedAuth(accountId, managedAuth.managedAuthPath, captured)\n\n    const now = Date.now()\n    const account: ClaudeManagedAccount = {\n      id: accountId,\n      email: captured.identity.email,\n      managedAuthPath: managedAuth.managedAuthPath,\n      managedAuthRuntime: managedAuth.managedAuthRuntime,\n      wslDistro: managedAuth.wslDistro,\n      wslLinuxAuthPath: managedAuth.wslLinuxAuthPath,\n      authMethod: 'subscription-oauth',\n      organizationUuid: captured.identity.organizationUuid,\n      organizationName: captured.identity.organizationName,\n      createdAt: now,\n      updatedAt: now,\n      lastAuthenticatedAt: now\n    }","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/claude-accounts/service.ts#L249-L285","documentation":"Thrown as DuplicateClaudeAccountError by persistCapturedClaudeAccount() when findDuplicateClaudeAccount() matches an existing managed account on email + organizationUuid + managedAuthRuntime + wslDistro. Orca treats re-authentication (doReauthenticateAccount) as the supported refresh path; a second add of the same account is rejected to avoid duplicate selection/rate-limit rows.","triggerScenarios":"User clicks 'Add account' and signs in with credentials identical (email, org, runtime, distro) to an already-managed account instead of using 'Re-authenticate'.","commonSituations":"User forgets they already added the account. Two entries for the same email in different orgs is allowed, but identical org+runtime is not. Switching runtimes (host vs wsl) for the same email/org is permitted only if runtime differs.","solutions":["Use the 'Re-authenticate' flow on the existing account instead of adding a new one.","If the duplicate is unwanted, remove the existing account first, then add.","Confirm the organizationUuid/runtime/wslDistro differ if you genuinely need two entries for the same email.","Clean up stale duplicate settings entries before adding."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (findDuplicateClaudeAccount(settings.claudeManagedAccounts, { email, organizationUuid, managedAuthRuntime, wslDistro })) {\n  // route user to re-authenticate instead\n}","typeGuard":"function isDuplicateAccountError(error: unknown): boolean {\n  return error instanceof Error && /already added/.test(error.message)\n}","tryCatchPattern":"try {\n  await addAccount(...)\n} catch (error) {\n  if (isDuplicateAccountError(error)) {\n    await reauthenticateAccount(existingId)\n    return\n  }\n  throw error\n}","preventionTips":["Offer 'Re-authenticate' for existing accounts instead of 'Add'.","Check for duplicates in the UI before showing the add option.","Remove unwanted duplicates before adding.","Differentiate entries by org/runtime if multiple are legitimate."],"tags":["claude-accounts","duplicate","validation","accounts"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}