{"record":{"id":"02b3cd72202f2410","repo":"makeplane/plane","slug":"user-not-found","errorCode":null,"errorMessage":"User not found","messagePattern":"User not found","errorType":"exception","errorClass":"CommandError","httpStatus":null,"severity":"error","filePath":"apps/api/plane/db/management/commands/create_project_member.py","lineNumber":43,"sourceCode":"        parser.add_argument(\"--user_email\", type=str, nargs=\"?\", help=\"User Email\")\n        parser.add_argument(\"--role\", type=int, nargs=\"?\", help=\"Role of the user in the project\")\n\n    def handle(self, *args: Any, **options: Any):\n        try:\n            if not options[\"project_id\"]:\n                raise CommandError(\"Project ID is required\")\n            if not options[\"user_email\"]:\n                raise CommandError(\"User Email is required\")\n\n            project_id = options[\"project_id\"]\n            user_email = options[\"user_email\"]\n            role = options.get(\"role\", 20)\n\n            print(f\"Role: {role}\")\n\n            user = User.objects.filter(email=user_email).first()\n            if not user:\n                raise CommandError(\"User not found\")\n\n            # Check if the project exists\n            project = Project.objects.filter(pk=project_id).first()\n            if not project:\n                raise CommandError(\"Project not found\")\n\n            # Check if the user exists in the workspace\n            if not WorkspaceMember.objects.filter(workspace=project.workspace, member=user, is_active=True).exists():\n                raise CommandError(\"User not member in workspace\")\n\n\n            if ProjectMember.objects.filter(project=project, member=user).exists():\n                # Update the project member\n                ProjectMember.objects.filter(project=project, member=user).update(\n                    is_active=True, role=role\n                )\n            else:\n                # Create the project member","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/makeplane/plane/blob/1c8a60f858d8472aa56e29994ec1c7926da2c6ce/apps/api/plane/db/management/commands/create_project_member.py#L25-L61","documentation":"Raised by `create_project_member` when `User.objects.filter(email=user_email).first()` returns None (lines 41-43). No Plane user matches the supplied email. Swallowed by the command's `except CommandError`. Note the filter is case-sensitive and not normalized (no `.lower()`), unlike `reactivate_workspace_member`.","triggerScenarios":"Passing `--user_email` for someone who has never signed in, or whose stored email casing differs.","commonSituations":"User not yet registered; casing mismatch; wrong domain.","solutions":["Verify the user: `python manage.py shell -c \"from plane.db.models import User; print(User.objects.filter(email='user@example.com').exists())\"`","Match the exact stored (lowercased) email.","Have the user sign in once to create the record."],"exampleFix":"# before\n--user_email User@Example.com   # no match (case-sensitive)\n# after\n--user_email user@example.com","handlingStrategy":"validation","validationCode":"python manage.py shell -c \"from plane.db.models import User; import sys; sys.exit(0 if User.objects.filter(email='user@example.com').exists() else 1)\"","typeGuard":"def user_exists(email: str) -> bool:\n    from plane.db.models import User\n    return User.objects.filter(email=email).exists()","tryCatchPattern":"# Command swallows CommandError internally; rely on a pre-check instead.","preventionTips":["Confirm the user has signed in once.","Match exact stored (lowercased) email; this command does NOT auto-lowercase.","Pre-check existence before invoking."],"tags":["django","management-command","validation","user-not-found","plane"],"backgroundTag":null,"analyzedSha":"1c8a60f858d8472aa56e29994ec1c7926da2c6ce","analyzedAt":"2026-08-12T14:44:31.636Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}