plandex-ai/plandex · error
error writing auth: auth not loaded
Error message
error writing auth: auth not loaded
What it means
Sentinel guard in writeCurrentAuth: the package-global Current session pointer is nil, so there is no loaded auth session to persist. Callers invoked writeCurrentAuth (directly or via setAuth/RefreshAuth) before loadCurrentAuth/initialization ran.
Source
Thrown at app/cli/auth/state.go:91
bytes, err := json.Marshal(accounts)
if err != nil {
return fmt.Errorf("error marshalling accounts: %v", err)
}
err = os.WriteFile(fs.HomeAccountsPath, bytes, os.ModePerm)
if err != nil {
return fmt.Errorf("error writing accounts: %v", err)
}
return nil
}
func writeCurrentAuth() error {
if Current == nil {
return fmt.Errorf("error writing auth: auth not loaded")
}
bytes, err := json.Marshal(Current)
if err != nil {
return fmt.Errorf("error marshalling auth: %v", err)
}
err = os.WriteFile(fs.HomeAuthPath, bytes, os.ModePerm)
if err != nil {
return fmt.Errorf("error writing auth: %v", err)
}
return nil
}
View on GitHub (pinned to e2d772072e)
Solutions
- Ensure auth state is loaded (loadCurrentAuth) before any write path runs
- Guard callers so they skip persisting when the user is not signed in
- Initialize Current to a non-nil session at CLI startup
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at app/cli/auth/state.go:91 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/25988461926f9d2f.
Report an issue: GitHub.