BerriAI/litellm · error · HTTPException

Invalid pipeline: {e}

Error message

Invalid pipeline: {e}

What it means

Validation guard in the test-pipeline endpoint: constructing the GuardrailPipeline Pydantic model from the request payload raised (bad mode, unknown step fields, missing guardrail names); the validation error is surfaced as an error response.

Source

Thrown at litellm/proxy/policy_engine/policy_endpoints.py:626

    ```bash
    curl -X POST "http://localhost:4000/policies/test-pipeline" \\
        -H "Authorization: Bearer <your_api_key>" \\
        -H "Content-Type: application/json" \\
        -d '{
            "pipeline": {
                "mode": "pre_call",
                "steps": [
                    {"guardrail": "pii-guard", "on_pass": "next", "on_fail": "block"}
                ]
            },
            "test_messages": [{"role": "user", "content": "My SSN is 123-45-6789"}]
        }'
    ```
    """
    try:
        validated_pipeline: Final = GuardrailPipeline(**request.pipeline)
    except Exception as e:
        raise HTTPException(status_code=400, detail=f"Invalid pipeline: {e}")

    data: Final = {
        "messages": request.test_messages,
        "model": "test",
        "metadata": {},
    }

    try:
        result: Final = await PipelineExecutor.execute_steps(
            steps=validated_pipeline.steps,
            mode=validated_pipeline.mode,
            data=data,
            user_api_key_dict=user_api_key_dict,
            call_type="completion",
            policy_name="test-pipeline",
        )
        return result.model_dump()
    except Exception as e:

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Fix the policy pipeline definition per the error detail (step names, order, parameters).
  2. Refer to the policy engine docs for the valid pipeline schema.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/proxy/policy_engine/policy_endpoints.py:626 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/6fdcc9fc4b578c33. Report an issue: GitHub.