{"record":{"id":"b703abbc20d04023","repo":"plandex-ai/plandex","slug":"error-selecting-account-v","errorCode":null,"errorMessage":"error selecting account: %v","messagePattern":"error selecting account: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/auth/account.go","lineNumber":42,"sourceCode":"\t\t\treturn fmt.Errorf(\"error signing in to new account: %v\", err)\n\t\t}\n\n\t\treturn nil\n\t}\n\n\tvar options []string\n\tfor _, account := range accounts {\n\t\toptions = append(options, fmt.Sprintf(\"<%s> %s\", account.UserName, account.Email))\n\t}\n\n\toptions = append(options, AddAccountOption)\n\n\t// either select from existing accounts or sign in/create account\n\n\tselectedOpt, err := term.SelectFromList(\"Select an account:\", options)\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error selecting account: %v\", err)\n\t}\n\n\tif selectedOpt == AddAccountOption {\n\t\terr := promptSignInNewAccount()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error prompting for sign in to new account: %v\", err)\n\t\t}\n\t\treturn nil\n\t}\n\n\tvar selected *shared.ClientAccount\n\tfor i, opt := range options {\n\t\tif selectedOpt == opt {\n\t\t\tselected = accounts[i]\n\t\t\tbreak\n\t\t}\n\t}\n","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/auth/account.go#L24-L60","documentation":"SelectOrSignInOrCreate in app/cli/auth/account.go wraps failures from term.SelectFromList as 'error selecting account: %v'. This happens when existing accounts are present and the CLI shows an interactive list; an error from the terminal selection UI (not the later 'account not found' check) is wrapped here.","triggerScenarios":"term.SelectFromList(\"Select an account:\", options) returns an error while the user picks among existing accounts — typically a terminal I/O problem (non-TTY stdin, interrupted read) or the user aborting/cancelling the selection.","commonSituations":"Running the CLI in CI, scripts, or with redirected stdin where no interactive list can render; pressing Ctrl+C/Esc during selection; terminal library failing on an unusual TERM setting or tiny terminal window.","solutions":["Run the command in an interactive terminal with a working TTY and standard TERM setting.","Avoid piping/redirecting stdin when invoking auth commands.","If selection keeps aborting, check whether the terminal emulator intercepts the cancel key and retry.","As a workaround, remove stale accounts from the store so the CLI goes straight to the sign-in prompt, or manage accounts via available non-interactive flags."],"exampleFix":"// before\nplandex sign-in < /dev/null   # non-interactive stdin -> error selecting account\n// after\nplandex sign-in               # run in a real interactive terminal","handlingStrategy":"validation","validationCode":"// Confirm an interactive TTY exists before presenting the account list\nfunc canInteract() bool {\n    fi, _ := os.Stdin.Stat()\n    return fi.Mode()&os.ModeCharDevice != 0\n}\nif !canInteract() {\n    return errors.New(\"account selection requires an interactive terminal\")\n}","typeGuard":"func isSelectAccountError(err error) bool {\n    return err != nil && strings.HasPrefix(err.Error(), \"error selecting account:\")\n}","tryCatchPattern":"if err := auth.SelectOrSignInOrCreate(); err != nil {\n    if isSelectAccountError(err) {\n        fmt.Fprintln(os.Stderr, \"account selection failed or was cancelled; rerun in an interactive terminal\")\n        os.Exit(1)\n    }\n    log.Fatal(err)\n}","preventionTips":["Avoid redirecting stdin or running auth commands from scripts/CI","Use a terminal emulator that doesn't swallow Esc/Ctrl+C during list selection","Keep TERM set to a supported value and the window large enough to render the list","Clean stale entries from the account store to keep the selection list small"],"tags":["auth","terminal","interactive","go"],"backgroundTag":"interactive-prompt-aborted","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}