litellm/tests/llm_translation/test_llm_response_utils
Shivaang 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
..
test_convert_dict_to_chat_completion.py fix(types): normalize null top_logprobs to [] in ChatCompletionTokenLogprob (#22245) 2026-02-28 15:59:29 -08:00
test_get_headers.py (fix) get_response_headers for Azure OpenAI (#6344) 2024-10-21 20:41:35 +05:30