plandex-ai/plandex · error

error getting all invites for org: %v

Error message

error getting all invites for org: %v

What it means

ListAllInvites selects every invite (accepted or pending) for an org. All non-nil errors from Conn.Select are wrapped with this message; an empty org simply yields a nil slice. It indicates the org-wide invite listing query failed at the database level.

Source

Thrown at app/server/db/invite_helpers.go:68

}

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 []*Invite
	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)

View on GitHub (pinned to e2d772072e)

Solutions

  1. Run pending DB migrations so SELECT * columns match the Invite struct.
  2. Validate orgId (UUID parse) in the handler before calling.
  3. Check connectivity/pool errors in the wrapped cause.
  4. Replace SELECT * with an explicit column list for resilience.

Example fix

// before
err := Conn.Select(&invites, "SELECT * FROM invites WHERE org_id = $1", orgId)

// after
err := Conn.Select(&invites, "SELECT id, org_id, email, name, inviter_id, org_role_id, accepted_at, created_at FROM invites WHERE org_id = $1", 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.ListAllInvites(orgId)
if err != nil {
    if pgErr, ok := asPG(err); ok && pgErr.Code == "42P01" {
        return fmt.Errorf("missing table — check migrations: %w", err)
    }
    return fmt.Errorf("list all invites: %w", err)
}

Prevention

When it happens

Trigger: Conn.Select("SELECT * FROM invites WHERE org_id = $1", orgId) fails: bad org_id format vs. uuid column, connection failure/timeout, or schema drift causing scan errors into the Invite struct. Called from ListAllInvitesHandler.

Common situations: Admin UI listing all invites right after a schema migration was added but the server binary (or Invite struct) is older, or transient DB outages during traffic spikes.

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


AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05). Data as JSON: /api/errors/f94572e071f5af65. Report an issue: GitHub.