Skip to content

fix(account-pool): reject duplicate OAuth account imports - #5709

Closed
MayankBansal12 wants to merge 4 commits into
get-bb:mainfrom
MayankBansal12:fix/account-pool-duplicate-machine-import
Closed

MayankBansal12 wants to merge 4 commits into
get-bb:mainfrom
MayankBansal12:fix/account-pool-duplicate-machine-import

Conversation

@MayankBansal12

@MayankBansal12 MayankBansal12 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Human comments

this PR prevents from duplicate imports for the same account by comparing accountId/emails for codex and claude accounts

image

Review Note:

One Claude login may have access to multiple organizations with separate usage limits. If those logins share the same account ID, this fix could mistakenly block adding the second organization to the pool. I couldn’t reproduce the Claude multi-organization edge case so it remains unverified.

What was wrong

Importing the same machine login repeatedly created duplicate Account Pooler entries because account creation always appended a record without checking whether the account was already connected.

What changed

Reject duplicate OAuth accounts inside the existing serialized store operation, before writing credentials. Explicit comparisons use provider identity first, then case-insensitive email, then tokens when metadata is missing. Distinct Codex workspace IDs remain separate. Rejected additions preserve the existing account, including its enabled state and priority. Codex device login surfaces the duplicate error. No daemon protocol or public API changes.

Tests cover each matching rule separately, with one concurrent-add regression for locking and orphan-secret prevention. Removed repeated RPC coverage of the same store behavior. Opus 5.5 at high implemented the readability pass.

How you verified

  • pnpm exec turbo run test typecheck lint --filter=bb-plugin-account-pool: 364 tests across 12 files passed; typecheck and lint passed (two existing warnings in unchanged UI files).
  • Independent mutations in an isolated copy confirmed the previous and retained tests catch duplicate acceptance, premature secret writes, missing email/token fallbacks, and provider/workspace mix-ups.
  • Further mutations confirmed the focused tests catch case-sensitive email matching, skipped Codex checks, missing provider-ID checks, checking outside the lock, unreadable-secret failures, and lost Codex duplicate-error passthrough.
  • Previously verified the machine-import UI in an isolated dev instance: duplicate error shown and only one account persisted.
  • Formatting and git diff --check passed.

AGENT GENERATED

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

This is an automated message. We have closed this pull request because it has been open for more than two weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant