{"record":{"id":"aab6bc00af949ec1","repo":"plandex-ai/plandex","slug":"error-validating-org-membership","errorCode":null,"errorMessage":"error validating org membership","messagePattern":"error validating org membership","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/handlers/auth_helpers.go","lineNumber":529,"sourceCode":"\t\t\tUser:      user,\n\t\t}\n\t}\n\n\tif parsed.OrgId == \"\" {\n\t\tlog.Println(\"no org id\")\n\t\tif raiseErr {\n\t\t\thttp.Error(w, \"no org id\", http.StatusUnauthorized)\n\t\t}\n\t\treturn nil\n\t}\n\n\t// validate the org membership\n\tisMember, err := db.ValidateOrgMembership(authToken.UserId, parsed.OrgId)\n\n\tif err != nil {\n\t\tlog.Printf(\"error validating org membership: %v\\n\", err)\n\t\tif raiseErr {\n\t\t\thttp.Error(w, \"error validating org membership\", http.StatusInternalServerError)\n\t\t}\n\t\treturn nil\n\t}\n\n\tif !isMember {\n\t\t// check if there's an invite for this user and accept it if so (adds the user to the org)\n\t\tinvite, err := db.GetActiveInviteByEmail(parsed.OrgId, user.Email)\n\n\t\tif err != nil {\n\t\t\tlog.Printf(\"error getting invite for org user: %v\\n\", err)\n\t\t\tif raiseErr {\n\t\t\t\thttp.Error(w, \"error getting invite for org user\", http.StatusInternalServerError)\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\n\t\tif invite != nil {\n\t\t\tlog.Println(\"accepting invite\")","sourceCodeStart":511,"sourceCodeEnd":547,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/auth_helpers.go#L511-L547","documentation":"db.ValidateOrgMembership(authToken.UserId, parsed.OrgId) returned an error, so execAuthenticate logs 'error validating org membership' and responds HTTP 500 when raiseErr is true. This is a backend/database failure while checking membership — distinct from the user simply not being a member.","triggerScenarios":"Database errors (connection failure, timeout, bad query) during the membership lookup for an authenticated request with an OrgId.","commonSituations":"DB outages or connection-pool exhaustion; schema drift between app version and database; transient network issues between app and database.","solutions":["Check database health and retry the request","Inspect server logs for the underlying error from db.ValidateOrgMembership","Verify the org_memberships table/schema matches the current app version","Add idempotent retry/backoff on transient DB failures"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := retry.WithBackoff(ctx, 3, func() error {\n\t_, err := client.OrgResource(ctx, orgID)\n\tvar apiErr *APIError\n\tif errors.As(err, &apiErr) && apiErr.StatusCode == 500 && strings.Contains(apiErr.Message, \"org membership\") {\n\t\treturn err // transient DB issue, retry\n\t}\n\treturn nil // non-retryable\n})","preventionTips":["Monitor DB connectivity; alert on membership-table query failures","Apply schema migrations consistently across environments","Use connection-pool limits and timeouts tuned for load","Make membership validation queries indexed and cheap"],"tags":["database","auth","internal-server-error"],"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-12T22:17:10.623Z"}