{"record":{"id":"d061a1bc0e4905c9","repo":"BerriAI/litellm","slug":"file-not-found-file-path-file-path","errorCode":null,"errorMessage":"File not found. file_path={file_path}","messagePattern":"File not found\\. file_path=(.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"enterprise/litellm_enterprise/enterprise_callbacks/llama_guard.py","lineNumber":44,"sourceCode":"from litellm.types.utils import CallTypesLiteral, Choices, ModelResponse\n\n\nclass _ENTERPRISE_LlamaGuard(CustomLogger):\n    # Class variables or attributes\n    def __init__(self, model_name: Optional[str] = None):\n        _model = model_name or litellm.llamaguard_model_name\n        if _model is None:\n            raise ValueError(\"model_name not set for LlamaGuard\")\n        self.model = _model\n        file_path = litellm.llamaguard_unsafe_content_categories\n        data = None\n\n        if file_path is not None:\n            try:\n                with open(file_path, \"r\") as file:\n                    data = file.read()\n            except FileNotFoundError:\n                raise Exception(f\"File not found. file_path={file_path}\")\n            except Exception as e:\n                raise Exception(f\"An error occurred: {str(e)}, file_path={file_path}\")\n\n        self.unsafe_content_categories = data\n\n        verbose_proxy_logger.debug(\n            f\"self.unsafe_content_categories: {self.unsafe_content_categories}\"\n        )\n\n    def print_verbose(self, print_statement):\n        try:\n            verbose_proxy_logger.debug(print_statement)\n            if litellm.set_verbose:\n                print(print_statement)  # noqa\n        except Exception:\n            pass\n\n    def set_custom_prompt_template(self, messages: list):","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/enterprise/litellm_enterprise/enterprise_callbacks/llama_guard.py#L26-L62","documentation":"Exception raised in _ENTERPRISE_LlamaGuard.__init__ when litellm.llamaguard_unsafe_content_categories points to a file path that does not exist. This optional file defines which LlamaGuard safety categories to enforce (S1–S13 etc.); when configured, the hook must be able to read it at init time.","triggerScenarios":"Setting llamaguard_unsafe_content_categories: \"./unsafe_categories.txt\" in litellm settings where the file is missing, the relative path resolves against a different working directory, or the container image lacks the file.","commonSituations":"Following LlamaGuard docs that reference a categories file without creating/mounting it; moving the proxy's working directory so relative paths break; forgetting to COPY the file into a Docker image.","solutions":["Create the file at the configured path with the LlamaGuard category definitions (one category token per line, e.g. S1..S13 subset).","Use an absolute path to avoid CWD-dependent resolution.","In Docker, COPY/mount the categories file and reference the mounted path.","If you want all categories enforced by default, unset llamaguard_unsafe_content_categories entirely (the hook skips file loading when it is None)."],"exampleFix":"# before\nlitellm_settings:\n  llamaguard_unsafe_content_categories: ./unsafe_categories.txt  # missing\n\n# after\nlitellm_settings:\n  llamaguard_unsafe_content_categories: /etc/litellm/unsafe_categories.txt\n# or remove the setting to use defaults","handlingStrategy":"validation","validationCode":"import os\n\ncats = os.environ.get(\"LLAMAGUARD_UNSAFE_CONTENT_CATEGORIES_FILE\")\nif cats and not os.path.isfile(cats):\n    raise SystemExit(f\"unsafe categories file missing: {cats}\")","typeGuard":null,"tryCatchPattern":"try:\n    guard = _ENTERPRISE_LlamaGuard(model_name=name)\nexcept Exception as e:\n    if \"File not found\" in str(e):\n        logger.error(\"create the categories file or unset llamaguard_unsafe_content_categories\")\n    raise","preventionTips":["Use an absolute path for llamaguard_unsafe_content_categories.","Ship the categories file inside the image (COPY) rather than assuming CWD.","Unset the setting entirely to use LlamaGuard defaults when a custom subset is unnecessary.","Validate the file exists in a startup probe."],"tags":["enterprise","llama-guard","file-io","config","startup"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}