plandex-ai/plandex · error
error getting invites and org names for email: %v
Error message
error getting invites and org names for email: %v
What it means
GetPendingInvitesForEmail selects unaccepted invites for an email address, used by GetAccessibleOrgsForUser to compute which orgs a user can join. sql.ErrNoRows is treated as 'no invites'; other errors are wrapped with this (slightly misleading) message about 'org names'. It is a DB failure of the pending-invites-by-email query.
Source
Thrown at app/server/db/invite_helpers.go:94
err := Conn.Select(&invites, "SELECT * FROM invites WHERE org_id = $1 AND accepted_at IS NOT NULL", orgId)
if err != nil {
return nil, fmt.Errorf("error getting accepted invites for org: %v", err)
}
return invites, nil
}
func GetPendingInvitesForEmail(email string) ([]*Invite, error) {
email = strings.ToLower(email)
var invites []*Invite
err := Conn.Select(&invites, "SELECT * FROM invites WHERE email = $1 AND accepted_at IS NULL", email)
if err != nil {
if err == sql.ErrNoRows {
return nil, nil
}
return nil, fmt.Errorf("error getting invites and org names for email: %v", err)
}
return invites, nil
}
func DeleteInvite(id string, tx *sqlx.Tx) error {
query := "DELETE FROM invites WHERE id = $1"
var err error
if tx == nil {
_, err = Conn.Exec(query, id)
} else {
_, err = tx.Exec(query, id)
}
if err != nil {
return fmt.Errorf("error deleting invite: %v", err)
}View on GitHub (pinned to e2d772072e)
Solutions
- Inspect the wrapped driver error to distinguish connectivity from schema problems.
- Run outstanding migrations if the error mentions unknown columns.
- Verify database connectivity/retry transient outages upstream.
- Normalize the email (trim/lowercase) before lookup to match stored rows.
- Remember nil,nil means 'no pending invites' — handle before treating errors.
Example fix
// before
invites, err := db.GetPendingInvitesForEmail(email)
if err != nil {
return nil, err
}
// after
invites, err := db.GetPendingInvitesForEmail(strings.ToLower(strings.TrimSpace(email)))
if err != nil {
return nil, fmt.Errorf("pending invites lookup: %w", err)
} Defensive patterns
Strategy: try-catch
Validate before calling
func validEmail(email string) bool {
_, err := mail.ParseAddress(strings.TrimSpace(email))
return err == nil
} Type guard
func hasPendingInvites(invites []*db.Invite, err error) bool {
return err == nil && len(invites) > 0
} Try / catch
invites, err := db.GetPendingInvitesForEmail(email)
if err != nil {
// DB failure during org-access computation; fail closed or degrade gracefully
logger.Error("pending invites lookup failed", "err", err)
return nil, fmt.Errorf("org access unavailable: %w", err)
}
// nil,nil means no pending invites Prevention
- Normalize emails before storing and querying.
- Apply migrations before code that expects new columns.
- Cache org-access lookups to reduce blast radius of DB hiccups at login.
- Distinguish the nil,nil 'no invites' path from errors in every caller.
- Alert on failures in this path — it blocks user authentication/access flows.
When it happens
Trigger: Conn.Select("SELECT * FROM invites WHERE email = $1 AND accepted_at IS NULL", email) fails with non-ErrNoRows: DB unreachable, statement timeout, schema drift causing scan failures, or email value that can't bind to the column type.
Common situations: User login/org-access computation during a DB outage; invites table altered by migration while old binaries run; empty email string passed accidentally (usually yields empty result, not error, but can surface binding issues).
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
Related errors
- error getting pending invites for org: %v
- error getting all invites for org: %v
- error getting accepted invites for org: %v
- error creating invite: %v
- error getting invite: %v
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/bce84d5807e0a0cd.
Report an issue: GitHub.