plandex-ai/plandex · error
error selecting account: account not found
Error message
error selecting account: account not found
What it means
SelectOrSignInOrCreate lists saved Plandex accounts and lets the user pick one interactively. After the user selects an option, the code maps the selected list entry back to its account by index. This error is thrown when no entry in the options list matches the string the user selected, so `selected` remains nil — meaning the account pointed to by the choice could not be found among the loaded accounts.
Source
Thrown at app/cli/auth/account.go:62
if selectedOpt == AddAccountOption {
err := promptSignInNewAccount()
if err != nil {
return fmt.Errorf("error prompting for sign in to new account: %v", err)
}
return nil
}
var selected *shared.ClientAccount
for i, opt := range options {
if selectedOpt == opt {
selected = accounts[i]
break
}
}
if selected == nil {
return fmt.Errorf("error selecting account: account not found")
}
selectedAuth := *selected
setAuth(&shared.ClientAuth{
ClientAccount: selectedAuth,
})
term.StartSpinner("")
orgs, apiErr := apiClient.ListOrgs()
term.StopSpinner()
if apiErr != nil {
return fmt.Errorf("error listing orgs: %v", apiErr.Msg)
}
org, err := resolveOrgAuth(orgs, selectedAuth.IsLocalMode)
View on GitHub (pinned to e2d772072e)
Solutions
- Re-run the command; if it persists, sign in fresh by choosing the 'Add another account' option so accounts are rebuilt from scratch.
- Delete the local accounts file (e.g. under ~/.plandex) and re-authenticate to regenerate consistent account entries.
- If developing, verify the loop at app/cli/auth/account.go:54 maps indices over `accounts` (not `options`) and that option labels are generated from the same slice order.
Example fix
// before
selected = accounts[i] // options index used directly; mismatch leaves selected nil
// after
accountsIdx := i // options includes trailing 'Add another account', accounts does not
if accountsIdx < len(accounts) {
selected = accounts[accountsIdx]
} Defensive patterns
Strategy: validation
Validate before calling
opts := buildOptions(accounts) // generate labels and accounts from the same slice
idx := indexOf(opts, selectedOpt)
if idx < 0 || idx >= len(accounts) {
return fmt.Errorf("unknown account option %q; re-run sign-in", selectedOpt)
} Type guard
func accountForOption(opts []string, accounts []shared.ClientAccount, sel string) (*shared.ClientAccount, bool) {
for i, o := range opts {
if o == sel && i < len(accounts) {
return &accounts[i], true
}
}
return nil, false
} Try / catch
if err := auth.SelectOrSignInOrCreate(); err != nil {
if strings.Contains(err.Error(), "account not found") {
// clear stale account store and re-authenticate
os.RemoveAll(accountsPath())
return auth.SelectOrSignInOrCreate()
}
return err
} Prevention
- Always generate option labels and the account list from the same slice so indices stay in sync.
- Include a stable key (account ID) in options rather than relying on display strings.
- Re-authenticate via 'Add another account' if the account picker ever shows stale entries.
When it happens
Trigger: The selected option string does not equal any generated `<UserName> <Email>` option (e.g. the accounts file changed between listing and selection, or options/accounts slices are out of sync because options includes the extra `Add another account` entry whose index maps past the accounts slice but that branch returns early).
Common situations: A stale or hand-edited accounts store on disk so rendered labels no longer match; running multiple Plandex CLI versions where the option label format changed; concurrent modification of ~/.plandex accounts while the picker is open.
Related errors
- error signing in: %v
- error selecting or signing in to account: %v
- error verifying email: %v
- error creating account: %v
- no org selected
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/88c33573b6955895.
Report an issue: GitHub.