BerriAI/litellm · error · ValueError

Each rule must specify at least a tool_name or tool_type reg

Error message

Each rule must specify at least a tool_name or tool_type regex

What it means

Pydantic model_validator on a tool-permission rule: both tool_name and tool_type are None after normalization, so the rule matches no tool and is unenforceable. At least one targeting field must be set.

Source

Thrown at litellm/types/proxy/guardrails/guardrail_hooks/tool_permission.py:52

        if isinstance(value, str):
            stripped: Final = value.strip()
            if not stripped:
                return None
            return stripped
        return value

    @field_validator("decision", mode="before")
    @classmethod
    def normalize_decision(cls, v):
        """Normalize decision to lowercase to handle case-insensitive input."""
        if isinstance(v, str):
            return v.lower()
        return v

    @model_validator(mode="after")
    def _ensure_target_present(self):
        if self.tool_name is None and self.tool_type is None:
            raise ValueError("Each rule must specify at least a tool_name or tool_type regex")
        return self


class ToolResult(BaseModel):
    """
    Represents a tool_result block to be added to the response
    """

    type: str = Field(default="tool_result", description="Should be 'tool_result'")
    tool_use_id: str = Field(description="ID of the tool use this result corresponds to")
    content: str = Field(description="Result content")
    is_error: bool = Field(default=True, description="Whether this is an error result")


class PermissionError(BaseModel):
    """
    Error information for permission denial
    """

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Add a tool_name or tool_type regex to every tool-permission rule.
  2. Delete rules that match nothing.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/types/proxy/guardrails/guardrail_hooks/tool_permission.py:52 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/7e3c6aff622756f9. Report an issue: GitHub.