{"record":{"id":"003bc1e91c7379f1","repo":"BerriAI/litellm","slug":"category-file-not-found-category-name-tried-y","errorCode":null,"errorMessage":"Category file not found: {category_name} (tried .yaml and .json)","messagePattern":"Category file not found: (.+?) \\(tried \\.yaml and \\.json\\)","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"litellm/proxy/guardrails/guardrail_endpoints.py","lineNumber":1439,"sourceCode":"\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\n        with open(category_file_path, \"r\") as f:\n            content: Final = f.read()\n\n        return {\n            \"category_name\": category_name,\n            \"yaml_content\": content,  # Keep key name for backwards compatibility\n            \"file_type\": file_type,\n        }\n    except Exception as e:\n        raise HTTPException(status_code=500, detail=f\"Error reading category file: {e}\")\n\n","sourceCodeStart":1421,"sourceCodeEnd":1457,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/guardrails/guardrail_endpoints.py#L1421-L1457","documentation":"Raised in the guardrail category-content endpoint when category_name passed the safe_join validation but neither {category_name}.yaml nor {category_name}.json exists in the packaged categories directory — i.e. a well-formed but unknown category name (e.g. 'bias_nonexistent'). Delivered as HTTP 404 naming both extensions that were tried.","triggerScenarios":"Thrown at litellm/proxy/guardrails/guardrail_endpoints.py:1439 when the library encounters an invalid state.","commonSituations":"No category file (.yaml/.json) exists for the requested category name.","solutions":["Check the category name spelling and that a .yaml or .json category file exists for it."],"exampleFix":"List available categories and retry with an existing one.","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-14T05:17:10.506Z"}