plandex-ai/plandex · error
no authenticated user
Error message
no authenticated user
What it means
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.
Source
Thrown at app/cli/lib/model_credentials.go:569
return false
}
}
return true
}
// emoji for satisfied vs missing
func mark(ok bool) string {
if ok {
return "✅"
}
return "❌"
}
var cachedAccountCredentials *types.AccountCredentials
func SetAccountCredentials(creds *types.AccountCredentials) error {
if auth.Current == nil {
return fmt.Errorf("no authenticated user")
}
dir := filepath.Join(fs.HomePlandexDir, auth.Current.UserId, auth.Current.OrgId)
err := os.MkdirAll(dir, 0700)
if err != nil {
return fmt.Errorf("error creating account credentials directory: %v", err)
}
path := filepath.Join(dir, "creds.json")
bytes, err := json.MarshalIndent(creds, "", " ")
if err != nil {
return fmt.Errorf("error marshalling account credentials: %v", err)
}
err = os.WriteFile(path, bytes, 0600)
if err != nil {
return fmt.Errorf("error writing account credentials: %v", err)
}
cachedAccountCredentials = creds
View on GitHub (pinned to e2d772072e)
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.
Example fix
// before
err := SetAccountCredentials(creds)
// after
if auth.Current == nil {
return fmt.Errorf("log in before connecting Claude Max")
}
err := SetAccountCredentials(creds) Defensive patterns
Strategy: try-catch
Validate before calling
if auth.Current == nil {
return fmt.Errorf("log in before connecting Claude Max")
} Type guard
func isLoggedIn() bool { return auth.Current != nil && auth.Current.UserId != "" && auth.Current.OrgId != "" } Try / catch
if err := SetAccountCredentials(creds); err != nil {
if strings.Contains(err.Error(), "no authenticated user") {
return fmt.Errorf("session required — run the login command, then retry")
}
return err
} Prevention
- 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.
When it happens
Trigger: Any caller (refreshClaudeMaxCredsIfNeeded, DisconnectClaudeMax, connectClaudeMaxOauth, refreshCreds) invokes SetAccountCredentials before login/plan auth has populated auth.Current.
Common situations: 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.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- error getting org session: %v
- error refreshing auth: auth not loaded
- auth.Current.UserId is empty
- no token
- error setting auth cookie: %v
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/57795459d3cef79c.
Report an issue: GitHub.