BerriAI/litellm · error · HTTPException

Invalid category name

Error message

Invalid category name

What it means

Raised in the guardrail category-content endpoint when safe_join rejects the requested category_name — practically always a path-traversal attempt (names containing ../ or absolute-path components) or characters that cannot be safely joined under the packaged categories directory. Delivered as HTTP 400 before any filesystem access happens.

Source

Thrown at litellm/proxy/guardrails/guardrail_endpoints.py:1427

        category_name: The name of the category (e.g., "bias_gender", "harmful_self_harm")

    Returns:
        The raw YAML or JSON content of the category file with file type indicator
    """
    # Get the categories directory path
    categories_dir: Final = os.path.join(
        os.path.dirname(__file__),
        "guardrail_hooks",
        "litellm_content_filter",
        "categories",
    )

    # Try to find the file with either .yaml or .json extension
    try:
        yaml_path: Final = safe_join(categories_dir, f"{category_name}.yaml")
        json_path: Final = safe_join(categories_dir, f"{category_name}.json")
    except ValueError:
        raise HTTPException(status_code=400, detail="Invalid category name")

    category_file_path = None
    file_type = None

    if os.path.exists(yaml_path):
        category_file_path = yaml_path
        file_type = "yaml"
    elif os.path.exists(json_path):
        category_file_path = json_path
        file_type = "json"
    else:
        raise HTTPException(
            status_code=404,
            detail=f"Category file not found: {category_name} (tried .yaml and .json)",
        )

    try:
        # Read and return the raw content

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Use a valid category name matching an available category file.

Example fix

Use only alphanumeric/underscore category names that correspond to existing files.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/proxy/guardrails/guardrail_endpoints.py:1427 when the library encounters an invalid state.

Common situations: The requested category name failed validation.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/764b140914efa4ef. Report an issue: GitHub.