{"record":{"id":"a6b0ee84e945c88f","repo":"BerriAI/litellm","slug":"custom-team-metadata-validate-must-be-an-async-fun","errorCode":null,"errorMessage":"custom_team_metadata_validate must be an async function","messagePattern":"custom_team_metadata_validate must be an async function","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"litellm/proxy/management_helpers/team_metadata_validation.py","lineNumber":121,"sourceCode":"\nasync def run_team_metadata_validation(\n    validator: TeamMetadataValidator,\n    payload: TeamMetadataValidationPayload,\n    premium_user: bool,\n    timeout_seconds: float,\n    unavailable_message: str,\n) -> None:\n    if premium_user is not True:\n        raise HTTPException(\n            status_code=status.HTTP_400_BAD_REQUEST,\n            detail={  # mutable-ok: HTTPException.detail has no immutable form\n                \"error\": f\"custom_team_metadata_validate is an Enterprise feature. {CommonProxyErrors.not_premium_user.value}\"\n            },\n        )\n    if not (\n        inspect.iscoroutinefunction(validator) or inspect.iscoroutinefunction(getattr(validator, \"__call__\", None))\n    ):\n        raise HTTPException(\n            status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,\n            detail={  # mutable-ok: HTTPException.detail has no immutable form\n                \"error\": \"custom_team_metadata_validate must be an async function\"\n            },\n        )\n\n    try:\n        raw_result: Final = await asyncio.wait_for(validator(payload), timeout=timeout_seconds)\n        result: Final = TeamMetadataValidationResult.model_validate(raw_result)\n    except Exception:  # noqa: BLE001  # fail closed: any validator failure must block the team write\n        raise HTTPException(\n            status_code=status.HTTP_503_SERVICE_UNAVAILABLE,\n            detail={\"error\": unavailable_message},  # mutable-ok: HTTPException.detail has no immutable form\n        )\n\n    if not result.valid:\n        raise HTTPException(\n            status_code=status.HTTP_400_BAD_REQUEST,","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/management_helpers/team_metadata_validation.py#L103-L139","documentation":"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.","triggerScenarios":"Thrown at litellm/proxy/management_helpers/team_metadata_validation.py:121 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Define custom_team_metadata_validate as an async function."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}