BerriAI/litellm · error · HTTPException

Invalid date format, expected YYYY-MM-DD: {e}

Error message

Invalid date format, expected YYYY-MM-DD: {e}

What it means

Date parsing in the tag-list range validator: datetime.strptime with '%Y-%m-%d' fails on malformed input, and the ValueError is converted into a 400 that names the expected format. At-fault input is a date string not in YYYY-MM-DD form.

Source

Thrown at litellm/proxy/management_endpoints/tag_management_endpoints.py:563

        return requested_tags
    except Exception as e:
        raise HTTPException(status_code=500, detail=str(e))


def _validate_tag_list_date_range(start_date: str | None, end_date: str | None) -> None:
    """Require both dates together, and enforce YYYY-MM-DD format with start <= end."""
    if (start_date is None) != (end_date is None):
        raise HTTPException(
            status_code=400,
            detail="start_date and end_date must be provided together",
        )
    if start_date is None:
        return
    try:
        start: Final = datetime.strptime(start_date, "%Y-%m-%d")
        end: Final = datetime.strptime(end_date, "%Y-%m-%d")
    except ValueError as e:
        raise HTTPException(
            status_code=400,
            detail=f"Invalid date format, expected YYYY-MM-DD: {e}",
        )
    if start > end:
        raise HTTPException(
            status_code=400,
            detail="start_date must be on or before end_date",
        )


@router.get(
    "/tag/list",
    tags=["tag management"],
    dependencies=[Depends(user_api_key_auth)],
)
async def list_tags(
    user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),
    start_date: str | None = Query(

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Use YYYY-MM-DD date format.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/proxy/management_endpoints/tag_management_endpoints.py:563 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/88dd549fa9bb586b. Report an issue: GitHub.