plandex-ai/plandex · error
error deleting invite: %v
Error message
error deleting invite: %v
What it means
DeleteInvite removes an invite row either on the standalone connection (Conn.Exec) or inside a supplied transaction (tx.Exec), depending on whether a tx is passed. Any Exec failure is wrapped with this message. It indicates the DELETE statement failed at the database level, not that the invite didn't exist.
Source
Thrown at app/server/db/invite_helpers.go:111
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)
}
return nil
}
func AcceptInvite(ctx context.Context, invite *Invite, inviteeId string) error {
err := WithTx(ctx, "accept invite", func(tx *sqlx.Tx) error {
_, err := tx.Exec(`UPDATE invites SET accepted_at = NOW(), invitee_id = $1 WHERE id = $2`, inviteeId, invite.Id)
if err != nil {
return fmt.Errorf("error accepting invite: %v", err)
}
// create org user
err = CreateOrgUser(invite.OrgId, inviteeId, invite.OrgRoleId, tx)
if err != nil {
return fmt.Errorf("error creating org user: %v", err)View on GitHub (pinned to e2d772072e)
Solutions
- Validate the invite id format (UUID parse) in the handler before calling DeleteInvite.
- Unwrap with errors.As(*pq.Error/*pgconn.PgError): 22P02 means bad id format; 23503 means FK restriction.
- If using the tx path, ensure no earlier statement in the transaction failed — check and rollback before this call.
- Check for dependent rows in referencing tables if FK errors appear.
- Verify DB connectivity if the cause is a connection error.
Example fix
// before: transaction reused after failure
if err := CreateOrgUser(...); err != nil {
// tx is now aborted, later DeleteInvite fails mysteriously
}
err := db.DeleteInvite(id, tx)
// after: handle failure and rollback before proceeding
if err := CreateOrgUser(...); err != nil {
return fmt.Errorf("create org user: %w", err) // tx rolled back by WithTx
}
if _, err := uuid.Parse(id); err != nil {
return fmt.Errorf("invalid invite id %q", id)
}
err := db.DeleteInvite(id, tx) Defensive patterns
Strategy: validation
Validate before calling
if _, err := uuid.Parse(inviteId); err != nil {
return fmt.Errorf("invalid invite id %q", inviteId)
} Type guard
func isInvalidTextRep(err error) bool {
var pgErr *pq.Error
return errors.As(err, &pgErr) && pgErr.Code == "22P02"
} Try / catch
if err := db.DeleteInvite(id, tx); err != nil {
if isInvalidTextRep(err) {
return fmt.Errorf("bad invite id: %w", err)
}
var pgErr *pq.Error
if errors.As(err, &pgErr) && pgErr.Code == "23503" {
return fmt.Errorf("invite referenced by other rows: %w", err)
}
return fmt.Errorf("delete invite: %w", err)
} Prevention
- Validate id format at the HTTP boundary before any DB call.
- Never continue using a tx after a failed statement — abort/rollback immediately.
- Check foreign keys referencing invites before enabling deletes.
- Keep driver error codes inspectable by wrapping with %w.
- Log invite id (sanitized) with the failure for traceability.
When it happens
Trigger: DELETE FROM invites WHERE id = $1 fails: malformed id vs. uuid column (invalid input syntax for type uuid), connection failure/timeout, transaction already aborted by an earlier statement, or FK restriction if other tables reference invites.
Common situations: DeleteInviteHandler given a tampered/malformed invite id; deleting inside a WithTx block after CreateOrgUser or another statement already failed and poisoned the transaction; FK constraints added by newer migrations blocking deletion.
Related errors
- error creating invite: %v
- error accepting invite: %v
- error adding org membership: %v
- error creating plan: %v
- error inserting lockable plan id: %v
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/78b8742cfbc3ee0b.
Report an issue: GitHub.