Files
litellm/tests/llm_translation/test_llm_response_utils
ShivaangandGitHub d524b79574 fix(types): normalize null top_logprobs to [] in ChatCompletionTokenLogprob (#22245)
Some OpenAI-compatible providers return null for top_logprobs when
logprobs=true but top_logprobs is unset or 0. The OpenAI spec requires
top_logprobs to be Array<TopLogprob> (never null), so this triggers
Pydantic validation errors while parsing responses.

Add a Pydantic v2 field_validator on ChatCompletionTokenLogprob that
normalizes None -> [] before type validation. This preserves the typed
List[TopLogprob] contract for downstream consumers while remaining
narrowly scoped to null only (other invalid types are still rejected).

Fixes #21932
2026-02-28 15:59:29 -08:00
..