{"record":{"id":"57795459d3cef79c","repo":"plandex-ai/plandex","slug":"no-authenticated-user","errorCode":null,"errorMessage":"no authenticated user","messagePattern":"no authenticated user","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/lib/model_credentials.go","lineNumber":569,"sourceCode":"\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n// emoji for satisfied vs missing\nfunc mark(ok bool) string {\n\tif ok {\n\t\treturn \"✅\"\n\t}\n\treturn \"❌\"\n}\n\nvar cachedAccountCredentials *types.AccountCredentials\n\nfunc SetAccountCredentials(creds *types.AccountCredentials) error {\n\tif auth.Current == nil {\n\t\treturn fmt.Errorf(\"no authenticated user\")\n\t}\n\tdir := filepath.Join(fs.HomePlandexDir, auth.Current.UserId, auth.Current.OrgId)\n\terr := os.MkdirAll(dir, 0700)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error creating account credentials directory: %v\", err)\n\t}\n\tpath := filepath.Join(dir, \"creds.json\")\n\tbytes, err := json.MarshalIndent(creds, \"\", \"  \")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error marshalling account credentials: %v\", err)\n\t}\n\terr = os.WriteFile(path, bytes, 0600)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error writing account credentials: %v\", err)\n\t}\n\n\tcachedAccountCredentials = creds\n","sourceCodeStart":551,"sourceCodeEnd":587,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/lib/model_credentials.go#L551-L587","documentation":"SetAccountCredentials persists the Claude Max account credentials (types.AccountCredentials) to creds.json under the user/org-scoped Plandex home directory. It first requires an authenticated session (auth.Current); if none exists there is no UserId/OrgId to scope the storage path, so it refuses with this error rather than writing credentials to an undefined location.","triggerScenarios":"Any caller (refreshClaudeMaxCredsIfNeeded, DisconnectClaudeMax, connectClaudeMaxOauth, refreshCreds) invokes SetAccountCredentials before login/plan auth has populated auth.Current.","commonSituations":"Running a refresh at CLI startup after the auth token was cleared; invoking connect/disconnect flows while logged out; a stale or corrupted local session state that left auth.Current nil.","solutions":["Ensure the user is logged in (run the CLI's auth/login command) before triggering Claude Max connect/refresh flows.","Check auth.Current for nil before calling SetAccountCredentials.","If logged in but auth.Current is nil, re-authenticate to rebuild the session state."],"exampleFix":"// before\nerr := SetAccountCredentials(creds)\n// after\nif auth.Current == nil {\n    return fmt.Errorf(\"log in before connecting Claude Max\")\n}\nerr := SetAccountCredentials(creds)","handlingStrategy":"try-catch","validationCode":"if auth.Current == nil {\n    return fmt.Errorf(\"log in before connecting Claude Max\")\n}","typeGuard":"func isLoggedIn() bool { return auth.Current != nil && auth.Current.UserId != \"\" && auth.Current.OrgId != \"\" }","tryCatchPattern":"if err := SetAccountCredentials(creds); err != nil {\n    if strings.Contains(err.Error(), \"no authenticated user\") {\n        return fmt.Errorf(\"session required — run the login command, then retry\")\n    }\n    return err\n}","preventionTips":["Gate all Claude Max connect/refresh flows behind a logged-in check.","Verify session validity at CLI startup and prompt re-auth when auth.Current is nil.","Never cache credentials when auth state is absent."],"tags":["auth","session","state"],"backgroundTag":"not-authenticated","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"}