stablyai/orca · warning · DuplicateClaudeAccountError

This Claude account is already added.

Error message

This Claude account is already added.

What it means

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.

Source

Thrown at src/main/claude-accounts/service.ts:267

    accountId: string,
    managedAuth: ManagedClaudeAuthLocation,
    previousSettings: ReturnType<Store['getSettings']>,
    captured: CapturedClaudeAuth
  ): Promise<ClaudeRateLimitAccountsState> {
    if (!captured.identity.email) {
      throw new Error('Claude login completed, but Orca could not resolve the account email.')
    }
    // Why: duplicate rows confuse selection and rate-limit tracking; re-authentication
    // is the supported way to refresh an account that is already managed.
    if (
      findDuplicateClaudeAccount(previousSettings.claudeManagedAccounts, {
        email: captured.identity.email,
        organizationUuid: captured.identity.organizationUuid,
        managedAuthRuntime: managedAuth.managedAuthRuntime,
        wslDistro: managedAuth.wslDistro
      })
    ) {
      throw new DuplicateClaudeAccountError('This Claude account is already added.')
    }
    await this.writeManagedAuth(accountId, managedAuth.managedAuthPath, captured)

    const now = Date.now()
    const account: ClaudeManagedAccount = {
      id: accountId,
      email: captured.identity.email,
      managedAuthPath: managedAuth.managedAuthPath,
      managedAuthRuntime: managedAuth.managedAuthRuntime,
      wslDistro: managedAuth.wslDistro,
      wslLinuxAuthPath: managedAuth.wslLinuxAuthPath,
      authMethod: 'subscription-oauth',
      organizationUuid: captured.identity.organizationUuid,
      organizationName: captured.identity.organizationName,
      createdAt: now,
      updatedAt: now,
      lastAuthenticatedAt: now
    }

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Use the 'Re-authenticate' flow on the existing account instead of adding a new one.
  2. If the duplicate is unwanted, remove the existing account first, then add.
  3. Confirm the organizationUuid/runtime/wslDistro differ if you genuinely need two entries for the same email.
  4. Clean up stale duplicate settings entries before adding.
Defensive patterns

Strategy: validation

Validate before calling

if (findDuplicateClaudeAccount(settings.claudeManagedAccounts, { email, organizationUuid, managedAuthRuntime, wslDistro })) {
  // route user to re-authenticate instead
}

Type guard

function isDuplicateAccountError(error: unknown): boolean {
  return error instanceof Error && /already added/.test(error.message)
}

Try / catch

try {
  await addAccount(...)
} catch (error) {
  if (isDuplicateAccountError(error)) {
    await reauthenticateAccount(existingId)
    return
  }
  throw error
}

Prevention

When it happens

Trigger: User clicks 'Add account' and signs in with credentials identical (email, org, runtime, distro) to an already-managed account instead of using 'Re-authenticate'.

Common situations: 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.

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/d4b1c4742162824f. Report an issue: GitHub.