{"record":{"id":"c413dfe9796375f1","repo":"plandex-ai/plandex","slug":"error-signing-in-v","errorCode":null,"errorMessage":"error signing in: %v","messagePattern":"error signing in: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/auth/account.go","lineNumber":122,"sourceCode":"\tfmt.Println()\n\n\tif !term.IsRepl {\n\t\tterm.PrintCmds(\"\", \"\")\n\t}\n\n\treturn nil\n}\n\nfunc SignInWithCode(code, host string) error {\n\tterm.StartSpinner(\"\")\n\tres, apiErr := apiClient.SignIn(shared.SignInRequest{\n\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 (","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/auth/account.go#L104-L140","documentation":"SignInWithCode wraps any ApiError returned by apiClient.SignIn (called with IsSignInCode=true) into 'error signing in: <server msg>'. It means the server rejected the pin-based sign-in-code exchange for the given host — the CLI reached the API but the API refused the sign-in. The underlying apiErr.Msg from the server is appended so the real cause is visible.","triggerScenarios":"apiClient.SignIn(shared.SignInRequest{Pin: code, IsSignInCode: true}, host) returns a non-nil apiErr: expired/invalid sign-in code, wrong or unreachable host, revoked pin, or server-side auth rejection during the code-based sign-in flow.","commonSituations":"User takes longer than the code's validity window to run the sign-in-with-code command; the code was already consumed; the CLI points at a different host (e.g. staging vs production) than the one that issued the code; the Plandex server was restarted with a fresh local-mode database invalidating issued codes.","solutions":["Read the appended apiErr.Msg — fix the specific server-reported cause (e.g. invalid or expired code).","Request a fresh sign-in code and retry the command promptly before it expires.","Verify the host matches the server that issued the code (check PLANDEX_HOST / configured host).","Check that the Plandex server is running and reachable at the host; retry after confirming server health."],"exampleFix":"// before: reusing an old code captured from an earlier email\nplandex auth sign-in-with-code OLD_CODE\n// after: request a fresh code and use it immediately\nplandex auth sign-in-with-code $(plandex auth request-code --email user@example.com)","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := auth.SignInWithCode(code, host)\nif err != nil {\n    if strings.Contains(err.Error(), \"expired\") || strings.Contains(err.Error(), \"invalid\") {\n        code = requestNewSignInCode() // fetch a fresh code, then retry once\n        err = auth.SignInWithCode(code, host)\n    }\n    if err != nil { return fmt.Errorf(\"sign-in failed: %w\", err) }\n}","preventionTips":["Use the sign-in code immediately after receiving it; codes are short-lived.","Keep the host consistent between code issuance and redemption (same PLANDEX_HOST).","Check server health/reachability before starting the auth flow.","Log apiErr.Msg upstream so the server's rejection reason is not lost."],"tags":["auth","cli","network","api"],"backgroundTag":"auth-signin-rejected","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"}