BerriAI/litellm · error · HTTPException

Error reading category file: {e}

Error message

Error reading category file: {e}

What it means

Raised in the guardrail category-content endpoint when opening or reading the resolved category file (.yaml/.json under the packaged categories directory) throws an unexpected OS-level exception — permissions, file removed between checks, or decode issues. The original exception text is embedded; delivered as HTTP 500 since it is a server-side file-access failure.

Source

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

        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
        with open(category_file_path, "r") as f:
            content: Final = f.read()

        return {
            "category_name": category_name,
            "yaml_content": content,  # Keep key name for backwards compatibility
            "file_type": file_type,
        }
    except Exception as e:
        raise HTTPException(status_code=500, detail=f"Error reading category file: {e}")


@router.get(
    "/guardrails/ui/major_airlines",
    tags=["Guardrails"],
    dependencies=[Depends(user_api_key_auth)],
)
async def get_major_airlines():
    """
    Get the major airlines list from IATA (competitor intent, airline type).
    Returns airline id, match variants (pipe-separated), and tags.
    """
    airlines_path: Final = os.path.join(
        os.path.dirname(__file__),
        "guardrail_hooks",
        "litellm_content_filter",
        "competitor_intent",
        "major_airlines.json",

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Check proxy logs for the file read error (permissions, malformed content).
  2. Validate the category file is well-formed YAML/JSON.

Example fix

python -c "import yaml; yaml.safe_load(open('category.yaml'))"
Defensive patterns

Strategy: try-catch

When it happens

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

Common situations: The category file exists but could not be read or parsed.


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