plandex-ai/plandex · error
error getting pending invites for org: %v
Error message
error getting pending invites for org: %v
What it means
ListPendingInvites selects all unaccepted invites for an org via Conn.Select. Unlike single-row getters, Select doesn't return sql.ErrNoRows for empty results, so ANY error here — including connection issues — is wrapped as this error. Empty result sets return a nil slice without error.
Source
Thrown at app/server/db/invite_helpers.go:57
err := Conn.Get(&invite, "SELECT * FROM invites WHERE org_id = $1 AND email = $2 AND accepted_at IS NULL", orgId, email)
if err != nil {
if err == sql.ErrNoRows {
return nil, nil
}
return nil, fmt.Errorf("error getting invite: %v", err)
}
return &invite, nil
}
func ListPendingInvites(orgId string) ([]*Invite, error) {
var invites []*Invite
err := Conn.Select(&invites, "SELECT * FROM invites WHERE org_id = $1 AND accepted_at IS NULL", orgId)
if err != nil {
return nil, fmt.Errorf("error getting pending invites for org: %v", err)
}
return invites, nil
}
func ListAllInvites(orgId string) ([]*Invite, error) {
var invites []*Invite
err := Conn.Select(&invites, "SELECT * FROM invites WHERE org_id = $1", orgId)
if err != nil {
return nil, fmt.Errorf("error getting all invites for org: %v", err)
}
return invites, nil
}
func ListAcceptedInvites(orgId string) ([]*Invite, error) {
var invites []*InviteView on GitHub (pinned to e2d772072e)
Solutions
- Check the wrapped cause: unknown column / scan errors mean migrations are out of date — run them.
- Validate orgId format before the call if the column is uuid.
- Verify DB connectivity and connection-pool configuration.
- Prefer explicit column lists over SELECT * to decouple the query from schema drift.
- Note an empty pending list is a nil slice with nil error — no fix needed for that case.
Example fix
// before (fragile to schema drift) err := Conn.Select(&invites, "SELECT * FROM invites WHERE org_id = $1 AND accepted_at IS NULL", orgId) // after err := Conn.Select(&invites, "SELECT id, org_id, email, name, inviter_id, org_role_id, created_at FROM invites WHERE org_id = $1 AND accepted_at IS NULL", orgId)
Defensive patterns
Strategy: try-catch
Validate before calling
if _, err := uuid.Parse(orgId); err != nil {
return fmt.Errorf("invalid org id %q", orgId)
} Try / catch
invites, err := db.ListPendingInvites(orgId)
if err != nil {
var pgErr *pq.Error
if errors.As(err, &pgErr) && pgErr.Code == "42P01" {
return fmt.Errorf("invites table missing — run migrations: %w", err)
}
return fmt.Errorf("list pending invites: %w", err)
} Prevention
- Run DB migrations as part of every deploy before serving traffic.
- Avoid SELECT * against structs; list columns explicitly to survive schema drift.
- Validate orgId format at the handler boundary.
- Set up DB health checks and alert on connection failures.
- Treat a nil slice as a normal empty result, not an error.
When it happens
Trigger: Conn.Select("SELECT * FROM invites WHERE org_id = $1 AND accepted_at IS NULL", orgId) fails: invalid org_id type/format (uuid cast error), DB connection failure/timeout, or invites table schema drift (SELECT * column scan mismatch against the Invite struct).
Common situations: ListPendingInvitesHandler called for an org id with wrong format, server deployed against an unmigrated database so SELECT * returns columns the Invite struct can't scan, or transient DB outage.
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 all invites for org: %v
- error getting accepted invites for org: %v
- error getting invites and org names for email: %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/0e5be294fcd1438d.
Report an issue: GitHub.