plandex-ai/plandex · error
no org id
Error message
no org id
What it means
The user authenticated but the request carried no org id (parsed.OrgId == ""), so execAuthenticate logs 'no org id' and returns HTTP 401 when raiseErr is true. Endpoints that call Authenticate with requireOrg=true need an org-scoped request.
Source
Thrown at app/server/handlers/auth_helpers.go:518
if err != nil {
log.Printf("error getting user: %v\n", err)
if raiseErr {
http.Error(w, "error getting user", http.StatusInternalServerError)
}
return nil
}
if !requireOrg {
return &types.ServerAuth{
AuthToken: authToken,
User: user,
}
}
if parsed.OrgId == "" {
log.Println("no org id")
if raiseErr {
http.Error(w, "no org id", http.StatusUnauthorized)
}
return nil
}
// validate the org membership
isMember, err := db.ValidateOrgMembership(authToken.UserId, parsed.OrgId)
if err != nil {
log.Printf("error validating org membership: %v\n", err)
if raiseErr {
http.Error(w, "error validating org membership", http.StatusInternalServerError)
}
return nil
}
if !isMember {
// check if there's an invite for this user and accept it if so (adds the user to the org)
invite, err := db.GetActiveInviteByEmail(parsed.OrgId, user.Email)View on GitHub (pinned to e2d772072e)
Solutions
- Have the client include OrgId in the auth header/payload for org-scoped requests
- Select an active org in the client before making the call
- Mint a new token that includes the org claim
- Use a non-org (requireOrg=false) auth path for user-only endpoints
Example fix
// before
req.Header.Set("Authorization", "Bearer "+token) // no org
// after
req.Header.Set("Authorization", "Bearer "+token)
req.Header.Set("X-Org-Id", orgID) Defensive patterns
Strategy: validation
Validate before calling
if orgID == "" {
return fmt.Errorf("org id required: select an org before calling org-scoped endpoints")
} Try / catch
if err := doCall(ctx); err != nil {
var apiErr *APIError
if errors.As(err, &apiErr) && apiErr.StatusCode == 401 && strings.Contains(apiErr.Message, "no org id") {
return promptOrgSelection() // attach OrgId and retry
}
return err
} Prevention
- Always include OrgId in auth payload/header for org-scoped calls
- Select a default org at client startup after login
- Refresh the org selection when switching workspaces
- Mint tokens that carry the org claim where supported
When it happens
Trigger: Requests parsed by GetAuthHeader that require an org context but whose token/header omitted OrgId, hitting org-scoped handlers.
Common situations: Clients that authenticate per-user but forget to select/pass an org; tokens minted before org support; API calls made outside an org workspace context.
Related errors
- no org selected
- no auth header
- not a member of org
- error loading accounts: %v
- error signing in to new account: %v
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/85b016c0533a15ad.
Report an issue: GitHub.