Significant-Gravitas/AutoGPT · error · ValueError
Cannot leave the default workspace
Error message
Cannot leave the default workspace
What it means
Raised by team_db.leave_team when the target workspace has isDefault=true. Users cannot leave their org's default workspace — org membership is expressed through it, so leaving would break the org-membership invariant. Plain ValueError from the DB layer.
Source
Thrown at autogpt_platform/backend/backend/api/features/orgs/team_db.py:137
return TeamResponse.from_db(ws)
await prisma.teammember.create(
data={
"teamId": ws_id,
"userId": user_id,
"status": "ACTIVE",
}
)
return TeamResponse.from_db(ws)
async def leave_team(ws_id: str, user_id: str) -> None:
"""Leave a workspace. Cannot leave the default workspace."""
ws = await prisma.team.find_unique(where={"id": ws_id})
if ws is None:
raise NotFoundError(f"Workspace {ws_id} not found")
if ws.isDefault:
raise ValueError("Cannot leave the default workspace")
await prisma.teammember.delete_many(where={"teamId": ws_id, "userId": user_id})
async def list_team_members(ws_id: str) -> list[TeamMemberResponse]:
"""List all active members of a workspace."""
members = await prisma.teammember.find_many(
where={"teamId": ws_id, "status": "ACTIVE"},
include={"User": True},
)
return [TeamMemberResponse.from_db(m) for m in members]
async def add_team_member(
ws_id: str,
user_id: str,
org_id: str,
is_admin: bool = False,View on GitHub (pinned to 9c8bb5550f)
Solutions
- Hide/disable the 'Leave' control for workspaces where isDefault is true
- If the user wants out of the org entirely, use the org leave/remove-member endpoints instead
- Filter default workspaces out of 'leaveable' lists in client state selectors
- In scripts, skip rows where isDefault before calling leave
Example fix
// before
memberships.map(m => <LeaveButton onClick={() => leave(m.teamId)} />);
// after
memberships.map(m =>
m.workspace.isDefault
? <span>Default workspace — leave the organization instead</span>
: <LeaveButton onClick={() => leave(m.teamId)} />
); Defensive patterns
Strategy: validation
Validate before calling
const ws = await getWorkspace(orgId, wsId);
if (ws.isDefault) throw new Error('Leave the organization instead of the default workspace'); Type guard
function isLeavableWorkspace(ws: TeamResponse): boolean {
return ws.isDefault !== true;
} Try / catch
try {
await leaveTeam(orgId, wsId);
} catch (e) {
if (e.message.includes('default workspace')) {
confirmLeaveOrganization(); // offer org-level leave instead
} else throw e;
} Prevention
- Hide leave actions for default workspaces
- Map 'leave default' intent to org leave flow
When it happens
Trigger: POST /api/orgs/{org_id}/workspaces/{ws_id}/leave where ws_id is the default workspace. Typically a UI that renders a 'Leave' action for every workspace membership row including the default one.
Common situations: Workspace list UI without special-casing isDefault; users trying to declutter by leaving the auto-created workspace; bulk 'leave all workspaces' scripts.
Related errors
- Cannot delete the default workspace
- Cannot change the default workspace's join policy
- Workspace does not belong to this organization
- Cannot self-join a PRIVATE workspace. Request an invite.
- User {user_id} is not a member of the organization
AI-assisted analysis of Significant-Gravitas/AutoGPT@9c8bb5550f (2026-08-14).
Data as JSON: /api/errors/f6f9d4ebd1e3ab5b.
Report an issue: GitHub.