{"record":{"id":"05c05003c299e266","repo":"makeplane/plane","slug":"error-user-email-is-not-a-member-of-workspace","errorCode":null,"errorMessage":"Error: User {email} is not a member of workspace {slug}","messagePattern":"Error: User (.+?) is not a member of workspace (.+?)","errorType":"console","errorClass":"CommandError","httpStatus":null,"severity":"error","filePath":"apps/api/plane/db/management/commands/reactivate_workspace_member.py","lineNumber":56,"sourceCode":"        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\n        # Raise error if the membership is not present\n        if not workspace_member:\n            raise CommandError(f\"Error: User {email} is not a member of workspace {slug}\")\n\n        # If already active, report without erroring\n        if workspace_member.is_active:\n            self.stdout.write(self.style.SUCCESS(f\"User {email} is already an active member of workspace {slug}\"))\n            return\n\n        # Reactivate the membership. update_fields keeps the write to the columns that change, and\n        # disable_auto_set_user stops BaseModel.save from nulling created_by/updated_by when there\n        # is no request user, as is the case in a management command.\n        workspace_member.is_active = True\n        workspace_member.save(update_fields=[\"is_active\", \"updated_at\"], disable_auto_set_user=True)\n\n        self.stdout.write(\n            self.style.SUCCESS(\n                f\"User {email} reactivated successfully in workspace {slug} as {workspace_member.get_role_display()}\"\n            )\n        )\n","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/makeplane/plane/blob/1c8a60f858d8472aa56e29994ec1c7926da2c6ce/apps/api/plane/db/management/commands/reactivate_workspace_member.py#L38-L74","documentation":"Raised by `reactivate_workspace_member` when no `WorkspaceMember` row links the (existing) user and (existing) workspace (lines 52-56). The membership was never created, or it was hard-deleted. Note the default manager excludes soft-deleted rows, so a soft-deleted membership would also surface here. This differs from an INACTIVE membership (`is_active=False`), which IS found here and then reactivated — so this error specifically means no row at all. Clean non-zero CommandError.","triggerScenarios":"The user exists and the workspace exists, but the user was never a member, or their membership row was hard-deleted rather than deactivated.","commonSituations":"User was removed via a path that deleted the row; attempting to reactivate someone who was only ever invited but never joined; wrong user/workspace pairing.","solutions":["Check including soft-deleted: `WorkspaceMember.all_objects.filter(workspace=..., member=...)` to see if a soft-deleted row exists.","If truly no membership, add the user to the workspace through the normal invite flow (UI or `WorkspaceMember.objects.create(...)`).","Confirm you paired the correct slug with the correct email."],"exampleFix":"# before — no WorkspaceMember row exists, so reactivation cannot work\npython manage.py reactivate_workspace_member my-ws user@example.com\n# after — re-invite the user to the workspace first (creates the membership),\n# then deactivate/reactivate as needed\npython manage.py shell -c \"from plane.db.models import Workspace, User, WorkspaceMember; ws=Workspace.objects.get(slug='my-ws'); u=User.objects.get(email='user@example.com'); WorkspaceMember.objects.create(workspace=ws, member=u, role=20, is_active=True)\"","handlingStrategy":"validation","validationCode":"python manage.py shell -c \"from plane.db.models import WorkspaceMember; import sys; sys.exit(0 if WorkspaceMember.objects.filter(workspace__slug='my-ws', member__email='user@example.com').exists() else 1)\"","typeGuard":"def membership_exists(slug: str, email: str) -> bool:\n    from plane.db.models import WorkspaceMember\n    return WorkspaceMember.objects.filter(workspace__slug=slug, member__email=email).exists()","tryCatchPattern":"try:\n    call_command('reactivate_workspace_member', slug, email)\nexcept CommandError as e:\n    if 'is not a member' in str(e):\n        # no membership row — re-invite the user to the workspace first\n        ...","preventionTips":["Distinguish inactive (is_active=False, reactivatable) from absent (no row — must re-invite).","Check WorkspaceMember.all_objects if a soft-deleted row is expected.","Re-invite the user via the normal flow if no membership row exists."],"tags":["django","management-command","validation","membership","not-found","plane"],"backgroundTag":null,"analyzedSha":"1c8a60f858d8472aa56e29994ec1c7926da2c6ce","analyzedAt":"2026-08-12T14:44:31.636Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}