plandex-ai/plandex · error
error getting org session: %v
Error message
error getting org session: %v
What it means
After auth is set locally, SelectOrSignInOrCreate calls apiClient.GetOrgSession() to validate that the client has an active org-scoped session on the server. If the server returns an error, it is wrapped as `error getting org session: %v`. Although auth was just saved, this confirms the org session is actually usable; failure here means subsequent org-scoped calls would fail.
Source
Thrown at app/cli/auth/account.go:100
return fmt.Errorf("error resolving org: %v", err)
}
err = setAuth(&shared.ClientAuth{
ClientAccount: *selected,
OrgId: org.Id,
OrgName: org.Name,
OrgIsTrial: org.IsTrial,
IntegratedModelsMode: org.IntegratedModelsMode,
})
if err != nil {
return fmt.Errorf("error setting auth: %v", err)
}
_, apiErr = apiClient.GetOrgSession()
if apiErr != nil {
return fmt.Errorf("error getting org session: %v", apiErr.Msg)
}
fmt.Printf("✅ Signed in as %s | Org: %s\n", color.New(color.Bold, term.ColorHiGreen).Sprintf("<%s> %s", Current.UserName, Current.Email), color.New(term.ColorHiCyan).Sprint(Current.OrgName))
fmt.Println()
if !term.IsRepl {
term.PrintCmds("", "")
}
return nil
}
func SignInWithCode(code, host string) error {
term.StartSpinner("")
res, apiErr := apiClient.SignIn(shared.SignInRequest{
Pin: code,
IsSignInCode: true,
}, host)View on GitHub (pinned to e2d772072e)
Solutions
- Re-run sign-in (`plandex signIn`); if it recurs immediately, sign out fully, clear stored auth, and sign in again.
- Verify server reachability and that the server time/clock is correct (large skew breaks session validation).
- Confirm your membership in the selected org hasn't been revoked; re-accept the invite if needed.
- Inspect the embedded apiErr.Msg to distinguish 401/403 (auth/permission) from 5xx/network causes and act accordingly.
Defensive patterns
Strategy: retry
Validate before calling
if !serverReachable(serverURL) {
return fmt.Errorf("cannot reach plandex server; fix connectivity before validating org session")
}
if clockSkewSeconds() > 60 {
return fmt.Errorf("local clock skewed %ds; sync NTP to avoid session rejection", clockSkewSeconds())
} Try / catch
if err := auth.SelectOrSignInOrCreate(); err != nil {
if strings.Contains(err.Error(), "error getting org session") {
if isUnauthorized(err) {
clearStoredAuth()
return auth.SelectOrSignInOrCreate() // full re-auth on 401
}
return retryWithBackoff(auth.SelectOrSignInOrCreate, 3) // transient
}
return err
} Prevention
- Keep server and client clocks synced (NTP) — skew invalidates fresh sessions.
- Treat immediate 401 after sign-in as a signal to fully clear and redo authentication.
- Confirm org membership hasn't been revoked when sessions fail right after selection.
- Retry transient 5xx/network failures with backoff instead of failing hard.
When it happens
Trigger: apiClient.GetOrgSession() returns a non-nil ApiErr — the freshly set org token is rejected (401/403), the org session expired between setAuth and the call, the server is unreachable, or the user lacks access to the resolved org.
Common situations: Server clock skew invalidating freshly issued tokens; user removed from the org moments after selection; reverse proxy/auth middleware rejecting the session; server restarted with rotated session keys.
Related errors
- error listing orgs: %v
- error resolving org: %v
- error signing in: %v
- error verifying email: %v
- error creating email verification: %v
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/65e803d790e72513.
Report an issue: GitHub.