plandex-ai/plandex · error
error getting invites for user: %v
Error message
error getting invites for user: %v
What it means
GetAccessibleOrgsForUser wraps a failure of GetPendingInvitesForEmail (the invitation-based access lookup) with this message. It is not itself a SQL statement here — it means the pending-invites query errored for the user's email. Zero pending invites is not an error.
Source
Thrown at app/server/db/org_helpers.go:48
orgIds = append(orgIds, ou.OrgId)
orgRoleIdByOrgId[ou.OrgId] = ou.OrgRoleId
}
if len(orgIds) > 0 {
query := fmt.Sprintf("SELECT %s FROM orgs WHERE id = ANY($1)", orgFields)
err = Conn.Select(&orgs, query, pq.Array(orgIds))
if err != nil {
return nil, fmt.Errorf("error getting orgs for user: %v", err)
}
} else {
log.Println("No orgs found for user")
return orgs, nil
}
// access via invitation
invites, err := GetPendingInvitesForEmail(user.Email)
if err != nil {
return nil, fmt.Errorf("error getting invites for user: %v", err)
}
orgIds = []string{}
for _, invite := range invites {
orgIds = append(orgIds, invite.OrgId)
orgRoleIdByOrgId[invite.OrgId] = invite.OrgRoleId
}
if len(orgIds) > 0 {
var orgsFromInvites []*Org
query := fmt.Sprintf("SELECT %s FROM orgs WHERE id = ANY($1)", orgFields)
err = Conn.Select(&orgsFromInvites, query, pq.Array(orgIds))
if err != nil {
return nil, fmt.Errorf("error getting orgs from invites: %v", err)
}
orgs = append(orgs, orgsFromInvites...)
}
View on GitHub (pinned to e2d772072e)
Solutions
- Check GetPendingInvitesForEmail and its wrapped error for the real SQL cause
- Run pending migrations for the invites table
- Align the invite struct db tags with the invites schema
- Add retry for transient DB failures
Example fix
// before
invites, err := GetPendingInvitesForEmail(user.Email)
if err != nil { return nil, fmt.Errorf("error getting invites for user: %v", err) }
// after
invites, err := GetPendingInvitesForEmail(user.Email)
if err != nil { return nil, fmt.Errorf("error getting invites for user (email=%s): %w", user.Email, err) } // %w preserves the cause for errors.Is/As Defensive patterns
Strategy: try-catch
Validate before calling
// ensure user.Email is non-empty before invite lookup
if user == nil || user.Email == "" { return nil, errors.New("user email required for invite lookup") } Type guard
func isInviteLookupError(err error) bool {
return err != nil && strings.Contains(err.Error(), "error getting invites for user")
} Try / catch
orgs, err := db.GetAccessibleOrgsForUser(user)
if err != nil {
if isInviteLookupError(err) {
log.Printf("invite lookup failed for %s: %v", user.Email, err) // inspect Unwrap for the SQL cause
}
return err
} Prevention
- Ensure GetPendingInvitesForEmail's table exists (migrations) and struct tags match its schema
- Use %w instead of %v so root causes remain inspectable
- Log the user email (safely) with the failure for triage
- Add retry for transient DB errors in sign-in paths
- Alert on repeated invite-lookup failures — usually schema or connectivity
When it happens
Trigger: GetPendingInvitesForEmail's underlying SELECT on the invites table fails: missing table, DB connection error, or scan mismatch on the invite struct.
Common situations: Invites table missing in an environment with stale migrations; invites schema changed (column renamed) breaking the invite struct scan; DB outage during sign-in.
Understand the failure class
Background: "query failed", "%w: SQL error" — wrapped database query errors in Go libraries explained — this error's family across 3 libraries.
Related errors
- error getting org: %v
- error deleting custom models: %v
- error deleting custom providers: %v
- error fetching model packs: %v
- error deleting model pack: %v
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/486a1ca9a831503f.
Report an issue: GitHub.