ComposioHQ/composio · error · ValidationError

{context}: slug is required

Error message

{context}: slug is required

What it means

Raised by Composio's custom-tool slug validator when an empty or None slug is supplied. Every custom tool and toolkit needs a non-empty slug because it becomes part of the tool's routed name.

Source

Thrown at python/composio/core/models/custom_tool.py:84

        Experimental as SessionAttachResponseExperimental,
    )
    from composio_client.types.tool_router.session_create_response import (
        Experimental as SessionCreateResponseExperimental,
    )
    from composio_client.types.tool_router.session_retrieve_response import (
        Experimental as SessionRetrieveResponseExperimental,
    )


# ────────────────────────────────────────────────────────────────
# Slug validation helpers
# ────────────────────────────────────────────────────────────────


def _validate_slug(slug: str, context: str) -> str:
    """Validate a custom tool or toolkit slug."""
    if not slug:
        raise ValidationError(f"{context}: slug is required")

    if not SLUG_REGEX.match(slug):
        raise ValidationError(
            f"{context}: slug must only contain alphanumeric characters, "
            f"underscores, and hyphens"
        )

    upper = slug.upper()
    if upper.startswith("LOCAL_"):
        raise ValidationError(
            f'{context}: slug must not start with "LOCAL_" — '
            f"this prefix is reserved for internal routing."
        )
    if upper.startswith("COMPOSIO_"):
        raise ValidationError(
            f'{context}: slug must not start with "COMPOSIO_" — '
            f"this prefix is reserved for Composio meta tools."
        )

View on GitHub (pinned to 64b1b85502)

Solutions

  1. Provide an explicit non-empty slug, e.g. slug="search_docs"
  2. If generating slugs programmatically, default to the function name (fn.__name__) when the computed slug is empty
  3. Add a fallback/slugify step before tool creation so user input can never arrive empty

Example fix

# before
Tool(slug="", name="Search", description="Search docs", input_params=SearchParams, callable=search)

# after
Tool(slug="search_docs", name="Search", description="Search docs", input_params=SearchParams, callable=search)
Defensive patterns

Strategy: validation

Validate before calling

import re
SLUG_RE = re.compile(r"^[a-zA-Z0-9_-]+$")
def safe_slug(slug: str, fallback: str) -> str:
    s = (slug or fallback or "").strip()
    if not s:
        raise ValueError("slug required")
    return s

Type guard

def is_valid_slug(slug: str | None) -> bool:
    return bool(slug) and bool(SLUG_RE.match(slug))

Try / catch

from composio.core.exceptions import ValidationError
try:
    tool = Tool(slug=slug, ...)
except ValidationError as e:
    slug = slugify(slug or fn.__name__)
    tool = Tool(slug=slug, ...)

Prevention

When it happens

Trigger: Creating a custom tool/toolkit via Tool(...) or toolkit decorators with slug="" or omitting it where no default is derived; calling _create_tool with an empty slug string.

Common situations: Copying an example and deleting the slug field; dynamically generating slugs from user data where the value can be empty; assuming the library auto-generates a slug from the function name when it doesn't in a given API path.

Related errors


AI-assisted analysis of ComposioHQ/composio@64b1b85502 (2026-08-28). Data as JSON: /api/errors/5451b56034a70643. Report an issue: GitHub.