{"record":{"id":"83dfcf3e28f75d26","repo":"plandex-ai/plandex","slug":"error-signing-in-to-new-account-v","errorCode":null,"errorMessage":"error signing in to new account: %v","messagePattern":"error signing in to new account: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/auth/account.go","lineNumber":24,"sourceCode":"\n\tshared \"plandex-shared\"\n\n\t\"github.com/fatih/color\"\n)\n\nconst AddAccountOption = \"Add another account\"\n\nfunc SelectOrSignInOrCreate() error {\n\taccounts, err := loadAccounts()\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error loading accounts: %v\", err)\n\t}\n\n\tif len(accounts) == 0 {\n\t\terr := promptSignInNewAccount()\n\t\tif err != nil {\n\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)","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/auth/account.go#L6-L42","documentation":"SelectOrSignInOrCreate in app/cli/auth/account.go wraps failures from promptSignInNewAccount() as 'error signing in to new account: %v'. This path runs when no existing accounts are stored, so the CLI immediately prompts for a fresh sign-in/sign-up; any failure inside that interactive flow (API error, invalid credentials, aborted prompt) is wrapped here.","triggerScenarios":"Calling SelectOrSignInOrCreate with len(accounts)==0 and promptSignInNewAccount() returning an error — failed email verification code, server API error during sign-in/sign-up, or the user aborting the interactive prompt.","commonSituations":"First-time setup against an unreachable or misconfigured server (local vs. hosted mode); invalid or expired verification code; server rejects the email domain; user cancels the prompt in a non-interactive terminal (CI, piped stdin).","solutions":["Check the wrapped underlying error to distinguish network/API failures from user cancellation.","Verify server connectivity and that the correct host/mode is configured (e.g. PLandex server URL or local mode).","Re-run interactively in a real TTY — the prompt cannot complete in CI or with piped stdin.","Confirm the email/verification code is correct and not expired; request a new code and retry."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Ensure the environment can complete an interactive sign-in before calling it\nfunc canPrompt() error {\n    if fi, _ := os.Stdin.Stat(); fi.Mode()&os.ModeCharDevice == 0 {\n        return errors.New(\"stdin is not a TTY; interactive sign-in unavailable\")\n    }\n    return nil\n}\n// also verify server reachability beforehand\nif err := checkServerReachable(serverURL); err != nil {\n    return err\n}","typeGuard":"func isSignInError(err error) bool {\n    return err != nil && strings.HasPrefix(err.Error(), \"error signing in to new account:\")\n}","tryCatchPattern":"if err := auth.SelectOrSignInOrCreate(); err != nil {\n    if isSignInError(err) {\n        fmt.Fprintln(os.Stderr, \"sign-in failed; check server connectivity and verification code, then retry\")\n        os.Exit(1)\n    }\n    log.Fatal(err)\n}","preventionTips":["Run sign-in only in an interactive TTY, never with piped stdin or in CI","Verify server URL/connectivity before first-time setup","Enter the verification code promptly before it expires","Check that the email domain is allowed by the server"],"tags":["auth","sign-in","interactive","go"],"backgroundTag":"sign-in-flow-failed","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}