{"record":{"id":"cf5154c89d3c35c3","repo":"Significant-Gravitas/AutoGPT","slug":"user-new-owner-id-is-not-a-member-of-org-org-id","errorCode":null,"errorMessage":"User {new_owner_id} is not a member of org {org_id}","messagePattern":"User (.+?) is not a member of org (.+?)","errorType":"http","errorClass":"NotFoundError","httpStatus":404,"severity":"error","filePath":"autogpt_platform/backend/backend/api/features/orgs/db.py","lineNumber":625,"sourceCode":"\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\"\n            END,\n            \"updatedAt\" = NOW()\n        WHERE \"orgId\" = $3 AND \"userId\" IN ($1, $2)\n        \"\"\",\n        current_owner_id,\n        new_owner_id,","sourceCodeStart":607,"sourceCodeEnd":643,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/orgs/db.py#L607-L643","documentation":"Error \"User {new_owner_id} is not a member of org {org_id}\" thrown in Significant-Gravitas/AutoGPT.","triggerScenarios":"Thrown at autogpt_platform/backend/backend/api/features/orgs/db.py:625 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Invite the user to the organization first, then transfer ownership.","Verify the user ID is correct."],"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"}