{"record":{"id":"dbed25a5284f1f3e","repo":"Significant-Gravitas/AutoGPT","slug":"cannot-remove-yourself-from-an-organization-ask-a","errorCode":null,"errorMessage":"Cannot remove yourself from an organization. Ask another admin to remove you, or transfer ownership first.","messagePattern":"Cannot remove yourself from an organization\\. Ask another admin to remove you, or transfer ownership first\\.","errorType":"http","errorClass":"ValueError","httpStatus":400,"severity":"error","filePath":"autogpt_platform/backend/backend/api/features/orgs/db.py","lineNumber":573,"sourceCode":"\nasync def remove_org_member(org_id: str, user_id: str, requesting_user_id: str) -> None:\n    \"\"\"Remove a member from an organization and all its workspaces.\n\n    Guards:\n    - Cannot remove the org owner (transfer ownership first)\n    - Cannot remove yourself (use leave flow instead)\n    - Cannot remove a user who has active schedules (transfer/cancel first)\n    - Cannot remove a user who would become org-less (no other org memberships)\n    \"\"\"\n    member = await prisma.orgmember.find_unique(\n        where={\"orgId_userId\": {\"orgId\": org_id, \"userId\": user_id}}\n    )\n    if member is None:\n        raise NotFoundError(f\"Member {user_id} not found in org {org_id}\")\n    if member.isOwner:\n        raise ValueError(\"Cannot remove the org owner. Transfer ownership first.\")\n    if user_id == requesting_user_id:\n        raise ValueError(\n            \"Cannot remove yourself from an organization. \"\n            \"Ask another admin to remove you, or transfer ownership first.\"\n        )\n\n    # Check if user would become org-less\n    other_memberships = await prisma.orgmember.count(\n        where={\n            \"userId\": user_id,\n            \"status\": \"ACTIVE\",\n            \"orgId\": {\"not\": org_id},\n            \"Org\": {\"deletedAt\": None},\n        }\n    )\n    if other_memberships == 0:\n        raise ValueError(\n            \"Cannot remove this member — they have no other organization memberships \"\n            \"and would be locked out. They must join or create another org first.\"\n        )","sourceCodeStart":555,"sourceCodeEnd":591,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/orgs/db.py#L555-L591","documentation":"Error \"Cannot remove yourself from an organization. Ask another admin to remove you, or transfer ownership first.\" thrown in Significant-Gravitas/AutoGPT.","triggerScenarios":"Thrown at autogpt_platform/backend/backend/api/features/orgs/db.py:573 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ask another admin to remove you, or transfer ownership and leave.","Use the leave-organization flow if available for non-owner members."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}