BerriAI/litellm · error · HTTPException

competitors list exceeds maximum of {MAX_COMPETITOR_NAMES}

Error message

competitors list exceeds maximum of {MAX_COMPETITOR_NAMES}

What it means

Pre-flight validation for LLM template enrichment: the supplied competitors array is longer than the MAX_COMPETITOR_NAMES cap, so the request is rejected with 400 before spending LLM tokens. At-fault input is data.competitors exceeding the configured maximum.

Source

Thrown at litellm/proxy/management_endpoints/policy_endpoints/endpoints.py:694

def _validate_enrichment_request(data: EnrichTemplateRequest) -> tuple[dict, dict, str]:
    """
    Validate enrichment request and return (template, llm_enrichment, brand_name).

    Raises HTTPException on validation failure.
    """
    templates: Final = _load_policy_templates_from_local_backup()
    template: Final = next((t for t in templates if t.get("id") == data.template_id), None)
    if template is None:
        raise HTTPException(status_code=404, detail=f"Template '{data.template_id}' not found")

    llm_enrichment: Final = template.get("llm_enrichment")
    if llm_enrichment is None:
        raise HTTPException(status_code=400, detail="Template does not support LLM enrichment")

    # Validate competitors list size if provided
    if data.competitors and len(data.competitors) > MAX_COMPETITOR_NAMES:
        raise HTTPException(
            status_code=400,
            detail=f"competitors list exceeds maximum of {MAX_COMPETITOR_NAMES}",
        )

    brand_name: Final = data.parameters.get(llm_enrichment["parameter"], "")
    if not brand_name:
        raise HTTPException(
            status_code=400,
            detail=f"Parameter '{llm_enrichment['parameter']}' is required",
        )

    return template, llm_enrichment, brand_name


@router.post(
    "/policy/templates/enrich",
    tags=["policy management"],
    dependencies=[Depends(user_api_key_auth)],

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Reduce the competitors list to at most the maximum allowed names.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/proxy/management_endpoints/policy_endpoints/endpoints.py:694 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/b101e4a83dfa9e33. Report an issue: GitHub.