{"record":{"id":"58d42d996187f6a5","repo":"plandex-ai/plandex","slug":"error-getting-accepted-invites-for-org-v","errorCode":null,"errorMessage":"error getting accepted invites for org: %v","messagePattern":"error getting accepted invites for org: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/server/db/invite_helpers.go","lineNumber":79,"sourceCode":"}\n\nfunc ListAllInvites(orgId string) ([]*Invite, error) {\n\tvar invites []*Invite\n\terr := Conn.Select(&invites, \"SELECT * FROM invites WHERE org_id = $1\", orgId)\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error getting all invites for org: %v\", err)\n\t}\n\n\treturn invites, nil\n}\n\nfunc ListAcceptedInvites(orgId string) ([]*Invite, error) {\n\tvar invites []*Invite\n\terr := Conn.Select(&invites, \"SELECT * FROM invites WHERE org_id = $1 AND accepted_at IS NOT NULL\", orgId)\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error getting accepted invites for org: %v\", err)\n\t}\n\n\treturn invites, nil\n}\n\nfunc GetPendingInvitesForEmail(email string) ([]*Invite, error) {\n\temail = strings.ToLower(email)\n\tvar invites []*Invite\n\terr := Conn.Select(&invites, \"SELECT * FROM invites WHERE email = $1 AND accepted_at IS NULL\", email)\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 invites and org names for email: %v\", err)\n\t}\n\n\treturn invites, nil","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/db/invite_helpers.go#L61-L97","documentation":"ListAcceptedInvites selects invites for an org where accepted_at IS NOT NULL. Any Conn.Select failure is wrapped with this message; an empty set is a valid nil-slice result. It means the accepted-invites listing query failed against the database.","triggerScenarios":"Conn.Select(\"SELECT * FROM invites WHERE org_id = $1 AND accepted_at IS NOT NULL\", orgId) fails: org_id format mismatch, DB connection failure, timeout, or scan error from schema drift on invites. Called by ListAcceptedInvitesHandler.","commonSituations":"Same as other list endpoints: unmigrated DB after an invites table change, invalid org id from the request, or DB outage under load.","solutions":["Apply schema migrations if the wrapped error indicates unknown columns or scan failures.","Validate the orgId format in the handler before the call.","Check DB connectivity and pool saturation.","Use explicit column lists instead of SELECT *."],"exampleFix":"// before\nerr := Conn.Select(&invites, \"SELECT * FROM invites WHERE org_id = $1 AND accepted_at IS NOT NULL\", orgId)\n\n// after\nerr := Conn.Select(&invites, \"SELECT id, org_id, email, name, inviter_id, org_role_id, accepted_at FROM invites WHERE org_id = $1 AND accepted_at IS NOT NULL\", orgId)","handlingStrategy":"try-catch","validationCode":"if _, err := uuid.Parse(orgId); err != nil {\n    return fmt.Errorf(\"invalid org id %q\", orgId)\n}","typeGuard":null,"tryCatchPattern":"invites, err := db.ListAcceptedInvites(orgId)\nif err != nil {\n    logger.Error(\"list accepted invites failed\", \"orgId\", orgId, \"err\", err)\n    http.Error(w, \"internal error\", http.StatusInternalServerError)\n    return\n}\n// empty result: invites == nil is a valid empty list","preventionTips":["Keep the invites schema and Invite struct in sync via migrations.","Validate orgId at the boundary.","Replace SELECT * with named columns.","Monitor connection-pool saturation under list-heavy admin traffic.","Handle empty lists (nil slice) without error paths."],"tags":["database","sql","select","list","schema-drift"],"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"}