BerriAI/litellm · error · HTTPException
custom_team_metadata_validate must be an async function
Error message
custom_team_metadata_validate must be an async function
What it means
HTTPException(500) from run_team_metadata_validation: the configured custom_team_metadata_validate hook is not awaitable — neither an async function nor an object whose __call__ is a coroutine. The proxy schema declares an async hook, so a sync callable cannot be invoked and the team write is aborted.
Source
Thrown at litellm/proxy/management_helpers/team_metadata_validation.py:121
async def run_team_metadata_validation(
validator: TeamMetadataValidator,
payload: TeamMetadataValidationPayload,
premium_user: bool,
timeout_seconds: float,
unavailable_message: str,
) -> None:
if premium_user is not True:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail={ # mutable-ok: HTTPException.detail has no immutable form
"error": f"custom_team_metadata_validate is an Enterprise feature. {CommonProxyErrors.not_premium_user.value}"
},
)
if not (
inspect.iscoroutinefunction(validator) or inspect.iscoroutinefunction(getattr(validator, "__call__", None))
):
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail={ # mutable-ok: HTTPException.detail has no immutable form
"error": "custom_team_metadata_validate must be an async function"
},
)
try:
raw_result: Final = await asyncio.wait_for(validator(payload), timeout=timeout_seconds)
result: Final = TeamMetadataValidationResult.model_validate(raw_result)
except Exception: # noqa: BLE001 # fail closed: any validator failure must block the team write
raise HTTPException(
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
detail={"error": unavailable_message}, # mutable-ok: HTTPException.detail has no immutable form
)
if not result.valid:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,View on GitHub (pinned to 77b7c6c40c)
Solutions
- Define custom_team_metadata_validate as an async function.
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at litellm/proxy/management_helpers/team_metadata_validation.py:121 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/a6b0ee84e945c88f.
Report an issue: GitHub.