{"record":{"id":"e0dc19e0e0c239c5","repo":"plandex-ai/plandex","slug":"error-getting-invite-v","errorCode":null,"errorMessage":"error getting invite: %v","messagePattern":"error getting invite: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/server/db/invite_helpers.go","lineNumber":31,"sourceCode":"\terr := 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)\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error creating invite: %v\", err)\n\t}\n\n\treturn nil\n}\n\nfunc GetInvite(id string) (*Invite, error) {\n\tvar invite Invite\n\terr := Conn.Get(&invite, \"SELECT * FROM invites WHERE id = $1\", id)\n\n\tif err != nil {\n\t\tif err == sql.ErrNoRows {\n\t\t\treturn nil, nil\n\t\t}\n\n\t\treturn nil, fmt.Errorf(\"error getting invite: %v\", err)\n\t}\n\n\treturn &invite, nil\n}\n\nfunc GetActiveInviteByEmail(orgId, email string) (*Invite, error) {\n\tvar invite Invite\n\terr := Conn.Get(&invite, \"SELECT * FROM invites WHERE org_id = $1 AND email = $2 AND accepted_at IS NULL\", orgId, email)\n\n\tif err != nil {\n\t\tif err == sql.ErrNoRows {\n\t\t\treturn nil, nil\n\t\t}\n\n\t\treturn nil, fmt.Errorf(\"error getting invite: %v\", err)\n\t}\n\n\treturn &invite, nil","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/db/invite_helpers.go#L13-L49","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\ninvite, err := db.GetInvite(r.FormValue(\"id\"))\n\n// after\nrawId := r.FormValue(\"id\")\nif _, err := uuid.Parse(rawId); err != nil {\n    http.Error(w, \"invalid invite id\", http.StatusBadRequest)\n    return\n}\ninvite, err := db.GetInvite(rawId)","handlingStrategy":"validation","validationCode":"func validInviteID(id string) bool {\n    _, err := uuid.Parse(id)\n    return err == nil\n}","typeGuard":"func isNotFoundNil(invite *db.Invite, err error) bool {\n    return err == nil && invite == nil\n}","tryCatchPattern":"invite, err := db.GetInvite(id)\nif err != nil {\n    var pgErr *pq.Error\n    if errors.As(err, &pgErr) && pgErr.Code == \"22P02\" {\n        http.Error(w, \"invalid invite id\", http.StatusBadRequest)\n        return\n    }\n    http.Error(w, \"internal error\", http.StatusInternalServerError)\n    return\n}\nif invite == nil {\n    http.Error(w, \"invite not found\", http.StatusNotFound)\n    return\n}","preventionTips":["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."],"tags":["database","sql","query","uuid","invalid-input"],"backgroundTag":"database-query-failed","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}