{"record":{"id":"0d8fc582bd8605da","repo":"plandex-ai/plandex","slug":"error-resolving-org-v","errorCode":null,"errorMessage":"error resolving org: %v","messagePattern":"error resolving org: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/auth/account.go","lineNumber":82,"sourceCode":"\n\tselectedAuth := *selected\n\n\tsetAuth(&shared.ClientAuth{\n\t\tClientAccount: selectedAuth,\n\t})\n\n\tterm.StartSpinner(\"\")\n\torgs, apiErr := apiClient.ListOrgs()\n\tterm.StopSpinner()\n\n\tif apiErr != nil {\n\t\treturn fmt.Errorf(\"error listing orgs: %v\", apiErr.Msg)\n\t}\n\n\torg, err := resolveOrgAuth(orgs, selectedAuth.IsLocalMode)\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error resolving org: %v\", err)\n\t}\n\n\terr = setAuth(&shared.ClientAuth{\n\t\tClientAccount:        *selected,\n\t\tOrgId:                org.Id,\n\t\tOrgName:              org.Name,\n\t\tOrgIsTrial:           org.IsTrial,\n\t\tIntegratedModelsMode: org.IntegratedModelsMode,\n\t})\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error setting auth: %v\", err)\n\t}\n\n\t_, apiErr = apiClient.GetOrgSession()\n\n\tif apiErr != nil {\n\t\treturn fmt.Errorf(\"error getting org session: %v\", apiErr.Msg)","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/auth/account.go#L64-L100","documentation":"After ListOrgs succeeds, SelectOrSignInOrCreate calls resolveOrgAuth(orgs, selectedAuth.IsLocalMode) to pick which organization to authenticate against. This error wraps any failure from that resolution — typically no orgs are available to the account or the desired org could not be matched. It is thrown before any org is written to the local auth store.","triggerScenarios":"resolveOrgAuth returns an error: the orgs list returned by the server is empty, the account's previously stored org no longer exists in the list, or in local-mode the local org is absent from the returned orgs.","commonSituations":"A developer account removed from all orgs; an org deleted or renamed server-side while local auth still references it; local-mode account used against a server that has no corresponding local org; trial org expired.","solutions":["Check which orgs the account actually belongs to (server admin UI or invite emails) and accept any pending org invite.","If the previously used org was deleted, clear local auth and sign in again to pick a valid org.","For local-mode mismatches, ensure the server has the local org set up or switch off local mode.","If developing, log orgs before resolveOrgAuth to confirm the expected org Id/Name is present in the list."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"orgs, err := listOrgsForAccount(account)\nif err != nil { return err }\nif len(orgs) == 0 {\n    return fmt.Errorf(\"account %s belongs to no orgs; accept an invite or create an org before signing in\", account.Email)\n}","typeGuard":"func hasUsableOrg(orgs []shared.Org, isLocalMode bool) (*shared.Org, bool) {\n    for i := range orgs {\n        if !isLocalMode || orgs[i].IsLocal {\n            return &orgs[i], true\n        }\n    }\n    return nil, false\n}","tryCatchPattern":"if err := auth.SelectOrSignInOrCreate(); err != nil {\n    if strings.Contains(err.Error(), \"error resolving org\") {\n        // org no longer available: wipe org selection and re-auth to pick another\n        clearStoredOrg()\n        return auth.SelectOrSignInOrCreate()\n    }\n    return err\n}","preventionTips":["Ensure the account is a member of at least one org (accept invites) before automating sign-in.","Don't cache a single org ID in scripts; re-resolve from the orgs list each session.","Keep local-mode accounts on servers that actually provision the local org."],"tags":["auth","orgs","configuration"],"backgroundTag":"org-not-found","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"}