BerriAI/litellm · error · ValueError

Invalid mode '{v}'. Must be one of: {sorted(VALID_PIPELINE_M

Error message

Invalid mode '{v}'. Must be one of: {sorted(VALID_PIPELINE_MODES)}

What it means

Pydantic validator on PipelineDefinition.mode: the mode string is not one of VALID_PIPELINE_MODES (pre_call / post_call hooks). The guardrail pipeline only knows how to attach to those hooks, so an unknown mode is rejected at policy parse time.

Source

Thrown at litellm/types/proxy/policy_engine/pipeline_types.py:80

    Defines ordered execution of guardrails with conditional actions.

    When present on a policy, the guardrails in `steps` are executed
    sequentially instead of independently.
    """

    mode: str = Field(description="Event hook: pre_call | post_call")
    steps: list[PipelineStep] = Field(
        description="Ordered list of pipeline steps. Must have at least 1 step.",
        min_length=1,
    )

    model_config = ConfigDict(extra="forbid")

    @field_validator("mode")
    @classmethod
    def validate_mode(cls, v: str) -> str:
        if v not in VALID_PIPELINE_MODES:
            raise ValueError(f"Invalid mode '{v}'. Must be one of: {sorted(VALID_PIPELINE_MODES)}")
        return v


class PipelineStepResult(BaseModel):
    """Result of executing a single pipeline step."""

    guardrail_name: str
    outcome: Literal["pass", "fail", "error"]
    action_taken: str
    modified_data: dict[str, Any] | None = None
    error_detail: str | None = None
    duration_seconds: float | None = None


class PipelineExecutionResult(BaseModel):
    """Result of executing an entire pipeline."""

    model_config = ConfigDict(arbitrary_types_allowed=True)

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Use one of the valid pipeline modes listed in the error: {sorted(VALID_PIPELINE_MODES)}.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/types/proxy/policy_engine/pipeline_types.py:80 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/7f5b9fe2c7a85d1b. Report an issue: GitHub.