{"record":{"id":"026d3e9eed4169a9","repo":"plandex-ai/plandex","slug":"error-validating-project-membership-v","errorCode":null,"errorMessage":"error validating project membership: %v","messagePattern":"error validating project membership: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/server/db/plan_helpers.go","lineNumber":467,"sourceCode":"\t// get plan\n\tplan, err := GetPlan(planId)\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error getting plan: %v\", err)\n\t}\n\n\tif plan == nil {\n\t\treturn nil, nil\n\t}\n\n\tif plan.OrgId != orgId {\n\t\treturn nil, nil\n\t}\n\n\thasProjectAccess, err := ProjectExists(orgId, plan.ProjectId)\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error validating project membership: %v\", err)\n\t}\n\n\tif !hasProjectAccess {\n\t\treturn nil, nil\n\t}\n\n\t// owner has access\n\tif plan.OwnerId == userId {\n\t\treturn plan, nil\n\t}\n\n\t// plan is shared with org\n\tif plan.SharedWithOrgAt != nil {\n\t\treturn plan, nil\n\t}\n\n\treturn nil, nil\n}","sourceCodeStart":449,"sourceCodeEnd":485,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/db/plan_helpers.go#L449-L485","documentation":"After loading the plan, ValidatePlanAccess checks that the plan's project exists under the given org by calling ProjectExists. If that COUNT query errors, it is wrapped with this message — signaling the membership/access check itself could not be performed, not that access was denied.","triggerScenarios":"ProjectExists(orgId, plan.ProjectId) fails — DB connectivity issue, scan failure, or the projects table is unavailable/unqueryable while validating plan access.","commonSituations":"Transient DB outages during authorization, plan rows referencing a project_id in an inconsistent state after partial deletes, schema mismatches on the projects table.","solutions":["Inspect the wrapped inner error for the root DB cause","Check DB connectivity and the projects table schema (org_id, id columns)","Verify plan.ProjectId is not empty/corrupted in the plans table","Retry the request if the failure was transient (e.g. connection pool exhaustion)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if plan.ProjectId == \"\" {\n    return errors.New(\"plan has no associated project; cannot validate membership\")\n}","typeGuard":null,"tryCatchPattern":"hasAccess, err := ProjectExists(orgId, plan.ProjectId)\nif err != nil {\n    return fmt.Errorf(\"membership check failed: %w\", err)\n}\nif !hasAccess {\n    return ErrForbidden\n}","preventionTips":["Ensure plan rows always reference a valid project_id (FK constraint)","Add retry with backoff for transient DB errors in auth paths","Monitor projects table schema changes","Verify orgId/projectId values before authorization"],"tags":["go","database","authorization","projects"],"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"}