{"record":{"id":"49d655a60b007e7a","repo":"plandex-ai/plandex","slug":"error-selecting-or-signing-in-to-account-v","errorCode":null,"errorMessage":"error selecting or signing in to account: %v","messagePattern":"error selecting or signing in to account: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/auth/account.go","lineNumber":134,"sourceCode":"\t\tPin:          code,\n\t\tIsSignInCode: true,\n\t}, host)\n\tterm.StopSpinner()\n\n\tif apiErr != nil {\n\t\treturn fmt.Errorf(\"error signing in: %v\", apiErr.Msg)\n\t}\n\n\treturn handleSignInResponse(res, host)\n}\n\nfunc promptInitialAuth() error {\n\tfmt.Println(\"👋 Hey there!\\nIt looks like this is your first time using Plandex on this computer.\")\n\n\terr := SelectOrSignInOrCreate()\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error selecting or signing in to account: %v\", err)\n\t}\n\n\treturn nil\n}\n\nconst (\n\t// SignInCloudOption = \"Plandex Cloud\"\n\tSignInLocalOption = \"Local mode host\"\n\tSignInOtherOption = \"Another host\"\n)\n\nfunc promptSignInNewAccount() error {\n\tselected, err := term.SelectFromList(\"Use local mode or another host?\", []string{SignInLocalOption, SignInOtherOption})\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error selecting sign in option: %v\", err)\n\t}\n","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/auth/account.go#L116-L152","documentation":"promptInitialAuth is a pure wrapper: it runs the first-time account setup (SelectOrSignInOrCreate) and re-wraps any failure as 'error selecting or signing in to account: %v'. It fires when a user with no stored accounts runs a command that triggers MustResolveAuth. The real cause is always the nested error from the account selection/sign-in flow.","triggerScenarios":"MustResolveAuth detects no existing accounts and calls promptInitialAuth; SelectOrSignInOrCreate fails (account list load failure, list selection failure, or any error from promptSignInNewAccount such as API or prompt errors).","commonSituations":"First run of the CLI on a new machine; after deleting the accounts config file; non-interactive environments (CI, scripts) where the interactive prompts cannot read input; corrupted accounts file making loadAccounts fail.","solutions":["Inspect the nested error after the colon — it identifies the failing sub-step (load, select, prompt, or API call).","Run the command in an interactive terminal so term.SelectFromList and user inputs can succeed.","If the accounts file is corrupt or empty unexpectedly, remove/reset it and re-run to start first-time setup cleanly.","Pre-authenticate non-interactively (e.g. complete sign-in once manually) before running in CI."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// check for an existing authenticated session before triggering first-time setup\nif auth.Current == nil && !term.IsInteractive() {\n    return fmt.Errorf(\"no Plandex account configured; run 'plandex auth' in an interactive terminal first\")\n}","typeGuard":null,"tryCatchPattern":"if err := promptInitialAuth(); err != nil {\n    var cause = errors.Unwrap(err) // inspect nested SelectOrSignInOrCreate failure\n    log.Printf(\"first-time auth failed: %v (cause: %v)\", err, cause)\n    return err\n}","preventionTips":["Complete first-time sign-in interactively before running headless/CI jobs.","Keep the accounts config file intact; back it up rather than hand-editing.","Unwrap the nested error to find the true failing sub-step before retrying.","Ensure a TTY is available whenever the auth flow may prompt."],"tags":["auth","cli","interactive-prompt"],"backgroundTag":"first-time-auth-setup-failed","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"}