{"record":{"id":"d6312a9a8d03a413","repo":"Significant-Gravitas/AutoGPT","slug":"member-user-id-not-found-in-org-org-id-after-u","errorCode":null,"errorMessage":"Member {user_id} not found in org {org_id} after update","messagePattern":"Member (.+?) not found in org (.+?) after update","errorType":"http","errorClass":"NotFoundError","httpStatus":404,"severity":"error","filePath":"autogpt_platform/backend/backend/api/features/orgs/db.py","lineNumber":552,"sourceCode":"        )\n\n    # Keep the default-workspace admin flag in step with the org role —\n    # add_org_member grants it at add time, so promotion/demotion via PATCH\n    # must sync it too or promoted admins stay denied on team-scoped checks.\n    if is_admin is not None:\n        default_ws = await prisma.team.find_first(\n            where={\"orgId\": org_id, \"isDefault\": True}\n        )\n        if default_ws:\n            await prisma.teammember.update_many(\n                where={\"teamId\": default_ws.id, \"userId\": user_id},\n                data={\"isAdmin\": is_admin},\n            )\n\n    members = await list_org_members(org_id)\n    match = next((m for m in members if m.user_id == user_id), None)\n    if match is None:\n        raise NotFoundError(f\"Member {user_id} not found in org {org_id} after update\")\n    return match\n\n\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:","sourceCodeStart":534,"sourceCodeEnd":570,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/orgs/db.py#L534-L570","documentation":"Error \"Member {user_id} not found in org {org_id} after update\" thrown in Significant-Gravitas/AutoGPT.","triggerScenarios":"Thrown at autogpt_platform/backend/backend/api/features/orgs/db.py:552 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the update; the member may have been removed concurrently.","Verify the user is still a member of the org before updating."],"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-15T22:17:37.221Z"}