Significant-Gravitas/AutoGPT · error · ValueError

Slug '{slug}' is already in use as an alias

Error message

Slug '{slug}' is already in use as an alias

What it means

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.

Source

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

async def create_org(
    name: str,
    slug: str,
    user_id: str,
    description: str | None = None,
) -> OrgResponse:
    """Create a team organization and make the user the owner.

    Raises:
        ValueError: If the slug is already taken by another org or alias.
    """
    existing_org = await prisma.organization.find_unique(where={"slug": slug})
    if existing_org:
        raise ValueError(f"Slug '{slug}' is already in use")
    existing_alias = await prisma.organizationalias.find_unique(
        where={"aliasSlug": slug}
    )
    if existing_alias:
        raise ValueError(f"Slug '{slug}' is already in use as an alias")

    # One transaction: a failure partway must not leave an org without its
    # default workspace, owner membership, profile, seat, or balance row.
    async with transaction() as tx:
        org = await tx.organization.create(
            data={
                "name": name,
                "slug": slug,
                "description": description,
                "isPersonal": False,
                "bootstrapUserId": user_id,
                "settings": "{}",
            }
        )

        await tx.orgmember.create(
            data={
                "orgId": org.id,

View on GitHub (pinned to 9c8bb5550f)

Solutions

  1. Pick a slug that is neither an active org slug nor a historical alias
  2. If you own the alias and truly need the slug, ask an admin to drop the alias row (no public API typically does this)
  3. In tests, use unique random slugs instead of renaming and reusing values
Defensive patterns

Strategy: try-catch

Validate before calling

taken = await prisma.organization.find_unique(where={"slug": slug})
alias = await prisma.organizationalalias.find_unique(where={"aliasSlug": slug})
if taken or alias:
    raise ValueError("slug reserved by org or rename alias")

Try / catch

try:
    org = await create_org(name=name, slug=slug, user_id=uid)
except ValueError as e:
    if "as an alias" in str(e):
        slug = f"{slug}-{suffix()}"  # alias slugs are never auto-reclaimed
        org = await create_org(name=name, slug=slug, user_id=uid)
    else:
        raise

Prevention

When it happens

Trigger: 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'.

Common situations: 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.

Related errors


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