BerriAI/litellm · error · ValueError

Invalid policy '{policy_name}': {e}

Error message

Invalid policy '{policy_name}': {e}

What it means

Raised while loading policies from YAML config: _parse_policy rejected the entry for the named policy (bad guardrail names, condition, or pipeline schema), so that policy is skipped and the parse error logged.

Source

Thrown at litellm/proxy/policy_engine/policy_registry.py:183

        Load policies from a configuration dictionary.

        Args:
            policies_config: Dictionary mapping policy names to policy definitions.
                            This is the raw config from the YAML file.
        """
        self._policies = {}
        self._config_policies = {}
        self._sources = {}
        self._policies_by_id = {}

        for policy_name, policy_data in policies_config.items():
            try:
                policy = self._parse_policy(policy_name, policy_data)
                self._policies[policy_name] = policy
                verbose_proxy_logger.debug("Loaded policy: %s", policy_name)
            except Exception as e:
                verbose_proxy_logger.error("Error loading policy '%s': %s", policy_name, e)
                raise ValueError(f"Invalid policy '{policy_name}': {e}") from e

        self._config_policies = dict(self._policies)
        self._sources = {policy_name: "config" for policy_name in self._policies}
        self._initialized = True
        verbose_proxy_logger.info("Loaded %s policies", len(self._policies))

    def _parse_policy(self, policy_name: str, policy_data: dict[str, Any]) -> Policy:
        """
        Parse a policy from raw configuration data.

        Args:
            policy_name: Name of the policy
            policy_data: Raw policy configuration

        Returns:
            Parsed Policy object
        """
        # Parse guardrails

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Fix the policy definition per the embedded error (invalid fields, unknown guardrails, bad pipeline).
  2. Validate the policy JSON against the documented schema before registering.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/proxy/policy_engine/policy_registry.py:183 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/e1930ce727c4db71. Report an issue: GitHub.