{"record":{"id":"155debd58b701d68","repo":"Significant-Gravitas/AutoGPT","slug":"slug-slug-is-already-in-use-as-an-alias","errorCode":null,"errorMessage":"Slug '{slug}' is already in use as an alias","messagePattern":"Slug '(.+?)' is already in use as an alias","errorType":"http","errorClass":"ValueError","httpStatus":400,"severity":"error","filePath":"autogpt_platform/backend/backend/api/features/orgs/db.py","lineNumber":235,"sourceCode":"async def create_org(\n    name: str,\n    slug: str,\n    user_id: str,\n    description: str | None = None,\n) -> OrgResponse:\n    \"\"\"Create a team organization and make the user the owner.\n\n    Raises:\n        ValueError: If the slug is already taken by another org or alias.\n    \"\"\"\n    existing_org = await prisma.organization.find_unique(where={\"slug\": slug})\n    if existing_org:\n        raise ValueError(f\"Slug '{slug}' is already in use\")\n    existing_alias = await prisma.organizationalias.find_unique(\n        where={\"aliasSlug\": slug}\n    )\n    if existing_alias:\n        raise ValueError(f\"Slug '{slug}' is already in use as an alias\")\n\n    # One transaction: a failure partway must not leave an org without its\n    # default workspace, owner membership, profile, seat, or balance row.\n    async with transaction() as tx:\n        org = await tx.organization.create(\n            data={\n                \"name\": name,\n                \"slug\": slug,\n                \"description\": description,\n                \"isPersonal\": False,\n                \"bootstrapUserId\": user_id,\n                \"settings\": \"{}\",\n            }\n        )\n\n        await tx.orgmember.create(\n            data={\n                \"orgId\": org.id,","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/orgs/db.py#L217-L253","documentation":"ValueError raised by create_org when the requested slug is not an org slug but matches an existing row in the organizationalalias table (aliases are old slugs kept after renames so old links keep working). The slug namespace is shared between orgs and aliases, so a renamed-away slug stays reserved.","triggerScenarios":"An org was renamed from 'acme' to 'acme-inc' — 'acme' becomes a RENAME alias — and someone then tries to create a new org with slug 'acme'.","commonSituations":"Attempting to reclaim a slug freed by another org's rename; brand reorganizations where an old name is re-registered later; tests reusing slugs after rename operations.","solutions":["Pick a slug that is neither an active org slug nor a historical alias","If you own the alias and truly need the slug, ask an admin to drop the alias row (no public API typically does this)","In tests, use unique random slugs instead of renaming and reusing values"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"taken = await prisma.organization.find_unique(where={\"slug\": slug})\nalias = await prisma.organizationalalias.find_unique(where={\"aliasSlug\": slug})\nif taken or alias:\n    raise ValueError(\"slug reserved by org or rename alias\")","typeGuard":null,"tryCatchPattern":"try:\n    org = await create_org(name=name, slug=slug, user_id=uid)\nexcept ValueError as e:\n    if \"as an alias\" in str(e):\n        slug = f\"{slug}-{suffix()}\"  # alias slugs are never auto-reclaimed\n        org = await create_org(name=name, slug=slug, user_id=uid)\n    else:\n        raise","preventionTips":["Remember renames permanently reserve old slugs — never plan to reuse them","Use unique disposable slugs in tests","Distinguish the alias message from the plain-slug message in error handling"],"tags":["orgs","validation","conflict","slug","alias"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}