plandex-ai/plandex · error
error getting invite: %v
Error message
error getting invite: %v
What it means
GetInvite fetches a single invite by id. A missing row is intentionally treated as not-found (returns nil, nil); any other query/scan failure is wrapped as this error. It signals a DB-level problem retrieving the invite row, not a missing invite.
Source
Thrown at app/server/db/invite_helpers.go:31
err := tx.QueryRow("INSERT INTO invites (org_id, email, name, inviter_id, org_role_id) VALUES ($1, $2, $3, $4, $5) RETURNING id", invite.OrgId, invite.Email, invite.Name, invite.InviterId, invite.OrgRoleId).Scan(&invite.Id)
if err != nil {
return fmt.Errorf("error creating invite: %v", err)
}
return nil
}
func GetInvite(id string) (*Invite, error) {
var invite Invite
err := Conn.Get(&invite, "SELECT * FROM invites WHERE id = $1", id)
if err != nil {
if err == sql.ErrNoRows {
return nil, nil
}
return nil, fmt.Errorf("error getting invite: %v", err)
}
return &invite, nil
}
func GetActiveInviteByEmail(orgId, email string) (*Invite, error) {
var invite Invite
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, nilView on GitHub (pinned to e2d772072e)
Solutions
- Validate/normalize the invite id (parse as UUID if the column is uuid) before calling GetInvite.
- Check database connectivity and logs for the wrapped driver error (connection refused/timeout).
- Confirm schema migrations have been applied to the invites table.
- If not-found handling matters, note callers must check for nil return separately — this error means a real failure, not a missing row.
Example fix
// before
invite, err := db.GetInvite(r.FormValue("id"))
// after
rawId := r.FormValue("id")
if _, err := uuid.Parse(rawId); err != nil {
http.Error(w, "invalid invite id", http.StatusBadRequest)
return
}
invite, err := db.GetInvite(rawId) Defensive patterns
Strategy: validation
Validate before calling
func validInviteID(id string) bool {
_, err := uuid.Parse(id)
return err == nil
} Type guard
func isNotFoundNil(invite *db.Invite, err error) bool {
return err == nil && invite == nil
} Try / catch
invite, err := db.GetInvite(id)
if err != nil {
var pgErr *pq.Error
if errors.As(err, &pgErr) && pgErr.Code == "22P02" {
http.Error(w, "invalid invite id", http.StatusBadRequest)
return
}
http.Error(w, "internal error", http.StatusInternalServerError)
return
}
if invite == nil {
http.Error(w, "invite not found", http.StatusNotFound)
return
} Prevention
- Validate id format (UUID) at the HTTP boundary before querying.
- Treat nil,nil as not-found and the error as a genuine failure — never conflate them.
- Keep migrations applied so the invites schema matches the struct.
- Monitor DB connectivity to catch transient outages early.
- Use %w wrapping to preserve driver error types for inspection.
When it happens
Trigger: Conn.Get on invites by id fails with anything other than sql.ErrNoRows: malformed id causing a type-cast error (e.g. non-UUID string against a uuid column), connection failure, timeout, or schema drift on the invites table.
Common situations: DeleteInviteHandler receiving an id whose format doesn't match the column type (invalid uuid syntax), database temporarily unreachable during a deploy, or running the server against a database with an outdated invites schema.
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 listing plans: %v
- error getting org owners: %v
- error creating invite: %v
- error getting pending invites for org: %v
- error getting all invites for org: %v
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/e0dc19e0e0c239c5.
Report an issue: GitHub.