{"record":{"id":"b48eaf1e924ca8e5","repo":"makeplane/plane","slug":"user-email-is-required","errorCode":null,"errorMessage":"User Email is required","messagePattern":"User Email is required","errorType":"exception","errorClass":"CommandError","httpStatus":null,"severity":"error","filePath":"apps/api/plane/db/management/commands/create_project_member.py","lineNumber":33,"sourceCode":"    ProjectUserProperty,\n)\n\n\nclass Command(BaseCommand):\n    help = \"Add a member to a project. If present in the workspace\"\n\n    def add_arguments(self, parser):\n        # Positional argument\n        parser.add_argument(\"--project_id\", type=str, nargs=\"?\", help=\"Project ID\")\n        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():","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/makeplane/plane/blob/1c8a60f858d8472aa56e29994ec1c7926da2c6ce/apps/api/plane/db/management/commands/create_project_member.py#L15-L51","documentation":"Raised by `create_project_member` when `--user_email` is missing or falsy (lines 32-33). `--user_email` uses `nargs=\"?\"` so argparse leaves it `None` and this check is reachable. Swallowed by the command's own `except CommandError` (lines 70-71).","triggerScenarios":"Running the command without `--user_email`, or with `--user_email ''`.","commonSituations":"Omitted flag; placeholder empty string in a templated script.","solutions":["Provide the flag: `python manage.py create_project_member --project_id <uuid> --user_email user@example.com`","Confirm the email is registered before running (see [87])."],"exampleFix":"# before\npython manage.py create_project_member --project_id <uuid>\n# after\npython manage.py create_project_member --project_id <uuid> --user_email user@example.com","handlingStrategy":"validation","validationCode":"import sys\nuser_email = ''  # from your script\nif not user_email:\n    sys.exit('--user_email is required')","typeGuard":"def has_user_email(value) -> bool:\n    return isinstance(value, str) and '@' in value and len(value) > 3","tryCatchPattern":"# Command swallows its own CommandError to stdout and returns 0;\n# validate the email is present and registered before running.","preventionTips":["Always pass --user_email (nargs='?' means argparse won't enforce it).","Normalize to lowercase to match stored emails.","Pre-check the user exists."],"tags":["django","management-command","validation","cli-args","plane"],"backgroundTag":null,"analyzedSha":"1c8a60f858d8472aa56e29994ec1c7926da2c6ce","analyzedAt":"2026-08-12T14:44:31.636Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}