Significant-Gravitas/AutoGPT · error · ValueError
Cannot delete the default workspace
Error message
Cannot delete the default workspace
What it means
Raised by team_db.delete_team when the target workspace has isDefault=true. Each org has exactly one default workspace that anchors membership and cannot be removed; deleting it would orphan the org's members. Plain ValueError from the DB layer; the DELETE route returns it as a 400-class failure.
Source
Thrown at autogpt_platform/backend/backend/api/features/orgs/team_db.py:92
return await get_team(ws_id)
# Guard: default workspace joinPolicy cannot be changed
if "joinPolicy" in update_data:
ws = await prisma.team.find_unique(where={"id": ws_id})
if ws and ws.isDefault:
raise ValueError("Cannot change the default workspace's join policy")
await prisma.team.update(where={"id": ws_id}, data=update_data)
return await get_team(ws_id)
async def delete_team(ws_id: str) -> None:
"""Delete a workspace. Cannot delete 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 delete the default workspace")
await prisma.team.delete(where={"id": ws_id})
async def join_team(ws_id: str, user_id: str, org_id: str) -> TeamResponse:
"""Self-join an OPEN workspace. User must be an org member."""
ws = await prisma.team.find_unique(where={"id": ws_id})
if ws is None:
raise NotFoundError(f"Workspace {ws_id} not found")
if ws.orgId != org_id:
raise ValueError("Workspace does not belong to this organization")
if ws.joinPolicy != "OPEN":
raise ValueError("Cannot self-join a PRIVATE workspace. Request an invite.")
# Verify user is actually an org member
org_member = await prisma.orgmember.find_unique(
where={"orgId_userId": {"orgId": org_id, "userId": user_id}}
)View on GitHub (pinned to 9c8bb5550f)
Solutions
- Hide or disable the delete action for workspaces where isDefault is true in the response payload
- To remove the workspace entirely, delete the organization instead (the default workspace dies with it)
- Create replacement workspaces first, migrate members, then delete the org if you are tearing down
- If testing, use a workspace created via create_team — those are never the default
Example fix
// before
{workspaces.map(ws => <DeleteButton onClick={() => del(ws.id)} />)}
// after
{workspaces.map(ws => (
ws.isDefault ? <Tooltip>Default workspace cannot be deleted</Tooltip> : <DeleteButton onClick={() => del(ws.id)} />
))} Defensive patterns
Strategy: validation
Validate before calling
const ws = await getWorkspace(orgId, wsId);
if (ws.isDefault) {
throw new Error('The default workspace cannot be deleted; delete the organization instead.');
} Type guard
function isDeletableWorkspace(ws: TeamResponse): boolean {
return ws.isDefault !== true;
} Try / catch
try {
await deleteWorkspace(orgId, wsId);
} catch (e) {
if (e.message.includes('Cannot delete the default workspace')) {
showToast('Default workspaces cannot be deleted');
} else throw e;
} Prevention
- Disable delete actions for isDefault rows in list UIs
- Default to org-level teardown when the default workspace must go
When it happens
Trigger: DELETE /api/orgs/{org_id}/workspaces/{ws_id} where ws_id is the default workspace (created automatically with the org, isDefault=true). Commonly triggered by 'delete' buttons in a workspace list UI that do not special-case the default row.
Common situations: UI iterates all workspaces and offers delete on each, including the default one; scripted cleanup that deletes every workspace in an org; user confusion between the personal/default workspace and user-created ones.
Related errors
- Cannot leave 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/39f09983d01d4d09.
Report an issue: GitHub.