Significant-Gravitas/AutoGPT · error · ValueError

Cannot transfer ownership to the same user

Error message

Cannot transfer ownership to the same user

What it means

Error "Cannot transfer ownership to the same user" thrown in Significant-Gravitas/AutoGPT.

Source

Thrown at autogpt_platform/backend/backend/api/features/orgs/db.py:613

    # For now, this is a placeholder for the schedule transfer requirement

    # Remove from all workspaces in this org
    workspaces = await prisma.team.find_many(where={"orgId": org_id})
    for ws in workspaces:
        await prisma.teammember.delete_many(where={"teamId": ws.id, "userId": user_id})

    # Remove org membership
    await prisma.orgmember.delete(
        where={"orgId_userId": {"orgId": org_id, "userId": user_id}}
    )


async def transfer_ownership(
    org_id: str, current_owner_id: str, new_owner_id: str
) -> None:
    """Transfer org ownership atomically. Both updates happen in one statement."""
    if current_owner_id == new_owner_id:
        raise ValueError("Cannot transfer ownership to the same user")

    current = await prisma.orgmember.find_unique(
        where={"orgId_userId": {"orgId": org_id, "userId": current_owner_id}}
    )
    if current is None or not current.isOwner:
        raise ValueError("Current user is not the org owner")

    new = await prisma.orgmember.find_unique(
        where={"orgId_userId": {"orgId": org_id, "userId": new_owner_id}}
    )
    if new is None:
        raise NotFoundError(f"User {new_owner_id} is not a member of org {org_id}")

    await prisma.execute_raw(
        """
        UPDATE "OrgMember"
        SET "isOwner" = CASE
                WHEN "userId" = $1 THEN false

View on GitHub (pinned to 9c8bb5550f)

Solutions

  1. Select a different member as the new owner.
  2. No action needed if the target user is already the owner.

When it happens

Trigger: Thrown at autogpt_platform/backend/backend/api/features/orgs/db.py:613 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Significant-Gravitas/AutoGPT@9c8bb5550f (2026-08-14). Data as JSON: /api/errors/c14082879587b32e. Report an issue: GitHub.