{"record":{"id":"4091a5034002cb67","repo":"makeplane/plane","slug":"error-email-is-required-4091a5","errorCode":null,"errorMessage":"Error: Email is required","messagePattern":"Error: Email is required","errorType":"exception","errorClass":"CommandError","httpStatus":null,"severity":"error","filePath":"apps/api/plane/db/management/commands/reactivate_workspace_member.py","lineNumber":35,"sourceCode":"        parser.add_argument(\"slug\", type=str, help=\"workspace slug\")\n        parser.add_argument(\"email\", type=str, help=\"user email\")\n\n    def handle(self, *args, **options):\n        # get the workspace slug and user email from console\n        slug = options.get(\"slug\") or \"\"\n        email = options.get(\"email\") or \"\"\n\n        # normalize before validating; emails are stored lowercased and stripped (User.save)\n        slug = slug.strip()\n        email = email.strip().lower()\n\n        # raise error if slug is not present\n        if not slug:\n            raise CommandError(\"Error: Workspace slug is required\")\n\n        # raise error if email is not present\n        if not email:\n            raise CommandError(\"Error: Email is required\")\n\n        # filter the user\n        user = User.objects.filter(email=email).first()\n\n        # Raise error if the user is not present\n        if not user:\n            raise CommandError(f\"Error: User with {email} does not exist\")\n\n        # filter the workspace\n        workspace = Workspace.objects.filter(slug=slug).first()\n\n        # Raise error if the workspace is not present\n        if not workspace:\n            raise CommandError(f\"Error: Workspace with slug {slug} does not exist\")\n\n        # Find the workspace membership (includes inactive members; soft-deleted are excluded by default manager)\n        workspace_member = WorkspaceMember.objects.filter(workspace=workspace, member=user).first()\n","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/makeplane/plane/blob/1c8a60f858d8472aa56e29994ec1c7926da2c6ce/apps/api/plane/db/management/commands/reactivate_workspace_member.py#L17-L53","documentation":"Raised by `reactivate_workspace_member` when `email` is empty after `.strip().lower()` (lines 25-35). `email` is a required positional argument (line 18), so argparse enforces presence; this branch is reachable only via programmatic invocation with a whitespace-only value. Clean non-zero CommandError (no swallowing try/except in this command).","triggerScenarios":"Calling `call_command('reactivate_workspace_member', slug='ws', email='   ')`; otherwise argparse blocks missing positionals.","commonSituations":"Wrapper script passing a blank/whitespace email; misconfigured env var.","solutions":["Invoke via CLI: `python manage.py reactivate_workspace_member my-workspace user@example.com`.","In wrappers, validate the email is non-empty before calling.","Confirm the user exists (see [97])."],"exampleFix":"# before\ncall_command('reactivate_workspace_member', slug='ws', email='')\n# after\ncall_command('reactivate_workspace_member', slug='ws', email='user@example.com')","handlingStrategy":"validation","validationCode":"import sys\nemail = ''  # from your script/env\nif not email or not email.strip():\n    sys.exit('email is required')","typeGuard":"def is_non_empty_email(value) -> bool:\n    return isinstance(value, str) and bool(value.strip()) and '@' in value","tryCatchPattern":"try:\n    call_command('reactivate_workspace_member', slug, email)\nexcept CommandError as e:\n    if 'Email is required' in str(e):\n        # whitespace-only email passed programmatically\n        ...","preventionTips":["Invoke via CLI so argparse enforces the positional.","Validate the email is non-empty in wrappers.","Confirm the user exists before running."],"tags":["django","management-command","validation","argparse","plane"],"backgroundTag":null,"analyzedSha":"1c8a60f858d8472aa56e29994ec1c7926da2c6ce","analyzedAt":"2026-08-12T14:44:31.636Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}