plandex-ai/plandex · error
error selecting org: org not found
Error message
error selecting org: org not found
What it means
A consistency error in selectOrg: after the user picks an org name from the list, the code looks up the matching *shared.Org by name. If no org in the slice matches the selected string, this sentinel error is returned. It indicates the selection list and the org slice are out of sync (or the selected value is unexpected).
Source
Thrown at app/cli/auth/org.go:133
if err != nil {
return nil, fmt.Errorf("error selecting org: %v", err)
}
if selected == CreateOrgOption {
return createOrg(isLocalMode)
}
var selectedOrg *shared.Org
for _, org := range orgs {
if org.Name == selected {
selectedOrg = org
break
}
}
if selectedOrg == nil {
return nil, fmt.Errorf("error selecting org: org not found")
}
return selectedOrg, nil
}
View on GitHub (pinned to e2d772072e)
Solutions
- Re-run the command so the org list and picker are rebuilt in sync
- Check for duplicate org names in the account and rename one on the server
- Verify no whitespace/case mangling of the selected value
- Report as a bug if it reproduces consistently — the picker and lookup should always agree
Example fix
// before
var selectedOrg *shared.Org
for _, org := range orgs {
if org.Name == selected {
// after (defensive: trim/normalize and select by index instead of name)
if idx >= 0 && idx < len(orgs) {
selectedOrg = orgs[idx]
} Defensive patterns
Strategy: type-guard
Validate before calling
// ensure the selected value is a known org name before lookup
valid := map[string]bool{}
for _, o := range orgs { valid[o.Name] = true }
if !valid[selected] && selected != CreateOrgOption {
return fmt.Errorf("unexpected selection %q", selected)
} Type guard
func orgSelected(orgs []*shared.Org, selected string) (*shared.Org, bool) {
for _, o := range orgs {
if o.Name == selected {
return o, true
}
}
return nil, false
} Try / catch
org, err := selectOrg(orgs, isLocalMode)
if err != nil {
if strings.Contains(err.Error(), "org not found") {
// rebuild the org list and retry selection once
}
return err
} Prevention
- Avoid duplicate org names in the account (rename on the server)
- Don't mutate the orgs slice between listing and lookup
- Re-run the command if the error appears once — it usually indicates stale state
- Report persistent occurrences as a CLI bug
When it happens
Trigger: selectOrg builds options from org names plus the "Create a new org" sentinel; if the value returned by term.SelectFromList is neither the sentinel nor matches any org.Name (e.g. duplicated org names caused a mismatch, or the list returned an unexpected value), selectedOrg stays nil.
Common situations: Custom or patched terminal input returning an altered string; org list mutated between rendering the list and the name lookup; whitespace/case differences in org names.
Related errors
- error selecting account: account not found
- error signing in: %v
- error selecting or signing in to account: %v
- error selecting sign in option: %v
- error prompting host: %v
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/dad9dfaadac913ef.
Report an issue: GitHub.