{"record":{"id":"2d23ef46e64ac39e","repo":"BerriAI/litellm","slug":"invalid-regex-in-allowed-param-patterns-for-rule","errorCode":null,"errorMessage":"Invalid regex in allowed_param_patterns for rule '{rule.id}': {exc}","messagePattern":"Invalid regex in allowed_param_patterns for rule '(.+?)': (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/proxy/guardrails/guardrail_hooks/tool_permission.py","lineNumber":116,"sourceCode":"                \"tool_type\": None,\n            }\n            if rule.tool_name is not None:\n                try:\n                    target_patterns[\"tool_name\"] = re.compile(rule.tool_name)\n                except re.error as exc:\n                    raise ValueError(f\"Invalid regex for tool_name in rule '{rule.id}': {exc}\") from exc\n            if rule.tool_type is not None:\n                try:\n                    target_patterns[\"tool_type\"] = re.compile(rule.tool_type)\n                except re.error as exc:\n                    raise ValueError(f\"Invalid regex for tool_type in rule '{rule.id}': {exc}\") from exc\n\n            rule_patterns: dict[str, re.Pattern] = {}\n            for path, pattern in (rule.allowed_param_patterns or {}).items():\n                try:\n                    rule_patterns[path] = re.compile(pattern)\n                except re.error as exc:\n                    raise ValueError(f\"Invalid regex in allowed_param_patterns for rule '{rule.id}': {exc}\") from exc\n\n            parsed_rules.append(rule)\n            compiled_targets[rule.id] = target_patterns\n            if rule_patterns:\n                compiled_patterns[rule.id] = rule_patterns\n\n        # Swap in the fully-built maps only after every rule compiles, so an\n        # invalid regex raises without leaving a partially-built ruleset (a\n        # missing compiled target is read as a match-all wildcard).\n        self.rules = parsed_rules\n        self._compiled_rule_targets = compiled_targets\n        self._compiled_rule_patterns = compiled_patterns\n\n    def update_in_memory_litellm_params(self, litellm_params: LitellmParams | dict) -> None:\n        \"\"\"Apply updated params in place, rebuilding the compiled rule state.\n\n        The base implementation only ``setattr``s raw fields, which would leave\n        ``_compiled_rule_targets`` / ``_compiled_rule_patterns`` (built in","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/guardrails/guardrail_hooks/tool_permission.py#L98-L134","documentation":"Error \"Invalid regex in allowed_param_patterns for rule '{rule.id}': {exc}\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/proxy/guardrails/guardrail_hooks/tool_permission.py:116 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the invalid regex in allowed_param_patterns for the referenced rule.","Validate each pattern with a regex tester before deploying the config."],"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-14T05:17:10.506Z"}