[Bugfix] Avoid leaking Pydantic repr in tool_choice error message (#47028)
Signed-off-by: muhammadfawaz1 <135441198+muhammadfawaz1@users.noreply.github.com> Co-authored-by: Mahad Durrani <114791389+mahadrehmann@users.noreply.github.com>
This commit is contained in:
co-authored by
Mahad Durrani
parent
c0e8e1f12a
commit
d35eba302f
@@ -2124,6 +2124,13 @@ async def test_tool_choice_validation_without_parser():
|
||||
assert isinstance(response_named, ErrorResponse)
|
||||
assert "tool_choice" in response_named.error.message
|
||||
assert "--tool-call-parser" in response_named.error.message
|
||||
# The function name should appear in a clean, readable form -
|
||||
# guards against leaking Pydantic's internal repr of the
|
||||
# ChatCompletionNamedToolChoiceParam/ChatCompletionNamedFunction
|
||||
# objects directly into the client-facing error message.
|
||||
assert "get_weather" in response_named.error.message
|
||||
assert "ChatCompletionNamedFunction" not in response_named.error.message
|
||||
assert "ChatCompletionNamedToolChoiceParam" not in response_named.error.message
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in New Issue
Block a user