{"record":{"id":"93cc9537389318c6","repo":"Significant-Gravitas/AutoGPT","slug":"current-user-is-not-the-org-owner","errorCode":null,"errorMessage":"Current user is not the org owner","messagePattern":"Current user is not the org owner","errorType":"http","errorClass":"ValueError","httpStatus":400,"severity":"error","filePath":"autogpt_platform/backend/backend/api/features/orgs/db.py","lineNumber":619,"sourceCode":"\n    # Remove org membership\n    await prisma.orgmember.delete(\n        where={\"orgId_userId\": {\"orgId\": org_id, \"userId\": user_id}}\n    )\n\n\nasync def transfer_ownership(\n    org_id: str, current_owner_id: str, new_owner_id: str\n) -> None:\n    \"\"\"Transfer org ownership atomically. Both updates happen in one statement.\"\"\"\n    if current_owner_id == new_owner_id:\n        raise ValueError(\"Cannot transfer ownership to the same user\")\n\n    current = await prisma.orgmember.find_unique(\n        where={\"orgId_userId\": {\"orgId\": org_id, \"userId\": current_owner_id}}\n    )\n    if current is None or not current.isOwner:\n        raise ValueError(\"Current user is not the org owner\")\n\n    new = await prisma.orgmember.find_unique(\n        where={\"orgId_userId\": {\"orgId\": org_id, \"userId\": new_owner_id}}\n    )\n    if new is None:\n        raise NotFoundError(f\"User {new_owner_id} is not a member of org {org_id}\")\n\n    await prisma.execute_raw(\n        \"\"\"\n        UPDATE \"OrgMember\"\n        SET \"isOwner\" = CASE\n                WHEN \"userId\" = $1 THEN false\n                WHEN \"userId\" = $2 THEN true\n                ELSE \"isOwner\"\n            END,\n            \"isAdmin\" = CASE\n                WHEN \"userId\" = $2 THEN true\n                ELSE \"isAdmin\"","sourceCodeStart":601,"sourceCodeEnd":637,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/orgs/db.py#L601-L637","documentation":"Error \"Current user is not the org owner\" thrown in Significant-Gravitas/AutoGPT.","triggerScenarios":"Thrown at autogpt_platform/backend/backend/api/features/orgs/db.py:619 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Only the current org owner can transfer ownership; sign in as the owner.","Ask the current owner to perform the transfer."],"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"}