{"record":{"id":"c5314c717d5582ac","repo":"plandex-ai/plandex","slug":"error-selecting-org-v","errorCode":null,"errorMessage":"error selecting org: %v","messagePattern":"error selecting org: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/auth/org.go","lineNumber":32,"sourceCode":"\n\tif len(orgs) == 0 {\n\t\tif isLocalMode {\n\t\t\torg, err = createOrg(isLocalMode)\n\t\t} else {\n\t\t\torg, err = promptNoOrgs()\n\t\t}\n\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error prompting no orgs: %v\", err)\n\t\t}\n\n\t} else if len(orgs) == 1 {\n\t\torg = orgs[0]\n\t} else {\n\t\torg, err = selectOrg(orgs, isLocalMode)\n\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error selecting org: %v\", err)\n\t\t}\n\t}\n\n\treturn org, nil\n}\n\nfunc promptNoOrgs() (*shared.Org, error) {\n\tfmt.Println(\"🧐 You don't have access to any orgs yet.\\n\\nTo join an existing org, ask an admin to either invite you directly or give your whole email domain access.\\n\\nOtherwise, you can go ahead and create a new org.\")\n\n\tshouldCreate, err := term.ConfirmYesNo(\"Create a new org now?\")\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error prompting create org: %v\", err)\n\t}\n\n\tif shouldCreate {\n\t\treturn createOrg(false)\n\t}","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/auth/org.go#L14-L50","documentation":"When the account belongs to more than one org, resolveOrgAuth runs selectOrg, an interactive picker over the org list. Any failure from selectOrg is wrapped as this error. It means the user's org could not be determined because selection failed.","triggerScenarios":"len(orgs) > 1 and selectOrg fails — the interactive selection prompt errors (non-TTY stdin/EOF, interrupted input) or the org selection API call inside selectOrg returns an ApiError.","commonSituations":"Multi-org user running the CLI in CI/non-interactive environments; Ctrl-C or piped stdin during the picker; server error while setting the chosen org as current; stale org list with a deleted org chosen.","solutions":["Run interactively and complete the org picker once; the choice is persisted to auth.json","Reduce ambiguity: leave/remove extra orgs, or ensure only one org membership if automation is needed","Check the wrapped inner error — if it's an API error, verify the selected org still exists and you have access","For CI, pre-select the org by running the picker manually before headless runs"],"exampleFix":"// before\nCI run with 2 orgs -> selectOrg EOF -> error selecting org\n// after\n# locally: plandex command, choose org (persisted in auth.json)\n# then rerun the command in CI with the same HOME","handlingStrategy":"validation","validationCode":"orgs, err := apiClient.ListOrgs()\nif err == nil && len(orgs) > 1 && !term.IsTerminal(os.Stdin.Fd()) {\n\treturn fmt.Errorf(\"multiple orgs require interactive selection; select an org first in a TTY\")\n}","typeGuard":"func needsInteractiveSelection(orgs []*shared.Org) bool { return len(orgs) > 1 && !term.IsTerminal(os.Stdin.Fd()) }","tryCatchPattern":"org, err := resolveOrgAuth(orgs, isLocalMode)\nif err != nil {\n\tif strings.Contains(err.Error(), \"selecting org\") {\n\t\tfmt.Fprintln(os.Stderr, \"Org selection failed; run once interactively to choose and persist an org.\", err)\n\t\tos.Exit(1)\n\t}\n\treturn err\n}","preventionTips":["Complete the org picker interactively once so the choice persists to auth.json","Don't pipe stdin into commands that may hit the org picker","Trim to a single org membership if the account must run headless","Handle Ctrl-C gracefully; rerun in a TTY"],"tags":["org","interactive-prompt","selection"],"backgroundTag":"non-interactive-terminal","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"}