{"record":{"id":"91aab325594ca27c","repo":"BerriAI/litellm","slug":"semanticguard-invalid-custom-routes-file-format-i","errorCode":null,"errorMessage":"SemanticGuard: invalid custom routes file format in {file_path}","messagePattern":"SemanticGuard: invalid custom routes file format in (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/proxy/guardrails/guardrail_hooks/semantic_guard/route_loader.py","lineNumber":62,"sourceCode":"        templates: Final = []\n        if os.path.isdir(ROUTE_TEMPLATES_DIR):\n            for fname in os.listdir(ROUTE_TEMPLATES_DIR):\n                if fname.endswith(\".yaml\"):\n                    templates.append(fname.replace(\".yaml\", \"\"))\n        return sorted(templates)\n\n    @staticmethod\n    def load_custom_routes_file(file_path: str) -> list[dict[str, Any]]:\n        \"\"\"Load custom routes from a YAML file.\"\"\"\n        if not os.path.exists(file_path):\n            raise ValueError(f\"SemanticGuard: custom routes file not found: {file_path}\")\n        with open(file_path, \"r\") as f:\n            data: Final = yaml.safe_load(f)\n        if isinstance(data, list):\n            return data\n        if isinstance(data, dict):\n            return [data]\n        raise ValueError(f\"SemanticGuard: invalid custom routes file format in {file_path}\")\n\n    @classmethod\n    def build_routes(\n        cls,\n        route_templates: list[str] | None,\n        custom_routes_file: str | None,\n        custom_routes: list[dict[str, Any]] | None,\n        global_threshold: float = DEFAULT_SEMANTIC_GUARD_SIMILARITY_THRESHOLD,\n    ) -> list[\"Route\"]:\n        \"\"\"Build semantic-router Route objects from templates + custom config.\"\"\"\n        from semantic_router.routers.base import Route\n\n        routes: Final[list[Route]] = []\n\n        if route_templates:\n            for template_name in route_templates:\n                template_data = cls.load_builtin_template(template_name)\n                threshold = template_data.get(\"similarity_threshold\", global_threshold)","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/guardrails/guardrail_hooks/semantic_guard/route_loader.py#L44-L80","documentation":"Error \"SemanticGuard: invalid custom routes file format in {file_path}\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/proxy/guardrails/guardrail_hooks/semantic_guard/route_loader.py:62 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the custom routes file to match the expected schema (list of routes with name and utterances).","Validate the YAML/JSON syntax of the routes file."],"exampleFix":null,"handlingStrategy":null,"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"}