{"record":{"id":"764b140914efa4ef","repo":"BerriAI/litellm","slug":"invalid-category-name","errorCode":null,"errorMessage":"Invalid category name","messagePattern":"Invalid category name","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"litellm/proxy/guardrails/guardrail_endpoints.py","lineNumber":1427,"sourceCode":"        category_name: The name of the category (e.g., \"bias_gender\", \"harmful_self_harm\")\n\n    Returns:\n        The raw YAML or JSON content of the category file with file type indicator\n    \"\"\"\n    # Get the categories directory path\n    categories_dir: Final = os.path.join(\n        os.path.dirname(__file__),\n        \"guardrail_hooks\",\n        \"litellm_content_filter\",\n        \"categories\",\n    )\n\n    # Try to find the file with either .yaml or .json extension\n    try:\n        yaml_path: Final = safe_join(categories_dir, f\"{category_name}.yaml\")\n        json_path: Final = safe_join(categories_dir, f\"{category_name}.json\")\n    except ValueError:\n        raise HTTPException(status_code=400, detail=\"Invalid category name\")\n\n    category_file_path = None\n    file_type = None\n\n    if os.path.exists(yaml_path):\n        category_file_path = yaml_path\n        file_type = \"yaml\"\n    elif os.path.exists(json_path):\n        category_file_path = json_path\n        file_type = \"json\"\n    else:\n        raise HTTPException(\n            status_code=404,\n            detail=f\"Category file not found: {category_name} (tried .yaml and .json)\",\n        )\n\n    try:\n        # Read and return the raw content","sourceCodeStart":1409,"sourceCodeEnd":1445,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/guardrails/guardrail_endpoints.py#L1409-L1445","documentation":"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.","triggerScenarios":"Thrown at litellm/proxy/guardrails/guardrail_endpoints.py:1427 when the library encounters an invalid state.","commonSituations":"The requested category name failed validation.","solutions":["Use a valid category name matching an available category file."],"exampleFix":"Use only alphanumeric/underscore category names that correspond to existing files.","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}