Restore explicit model_id validation to fix test failures (#4299)

The walrus operator refactor silently dropped the empty-string validation,
causing test_init_model_id_kwarg_empty_string to fail. Restore the explicit
None check and ValueError raise for empty model_id.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Evan Mattson
2026-02-27 08:30:30 +09:00
co-authored by Copilot
parent 5bed03ee4b
commit 1d2965fff6
@@ -180,7 +180,10 @@ class AzureOpenAIResponsesClient( # type: ignore[misc]
client: AzureOpenAIResponsesClient[MyOptions] = AzureOpenAIResponsesClient()
response = await client.get_response("Hello", options={"my_custom_option": "value"})
"""
if (model_id := kwargs.pop("model_id", None)) and not deployment_name:
model_id = kwargs.pop("model_id", None)
if model_id is not None and not str(model_id).strip():
raise ValueError("model_id must not be empty")
if model_id is not None and deployment_name is None:
deployment_name = str(model_id)
# Project client path: create OpenAI client from an Azure AI Foundry project