Repository navigation
fix(http-tool): serialize formatted arguments in JSON mode - #8349
Open
Winoren (Winoren) wants to merge 1 commit into
Open
Winoren (Winoren) wants to merge 1 commit into
Winoren (Winoren) wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why are these changes needed?
HttpToolaccepts JSON Schema string formats such asdate,date-time, anduuid. The generated input model validates those strings into Pythondate,datetime, andUUIDinstances.run()currently exports them withmodel_dump()in Python mode and passes the resulting objects to HTTPX's JSON encoder. Valid tool arguments consequently raiseTypeError: Object of type ... is not JSON serializablebefore any HTTP request is sent.Export arguments in Pydantic's JSON mode so validated formats become JSON-compatible values. Path parameters are still removed from the body, and ordinary boolean/integer values retain their JSON types.
Nine regression cases cover all three formats with POST, PUT, and PATCH through the real
HttpTool.run_json()and HTTPX request encoding. Only the transport is replaced withMockTransport; no external service is called by these cases.Related issue number
Found while inspecting the current HTTP tool implementation; no linked issue. This is separate from the existing configuration round-trip and path-escaping fixes.
Validation
Based on upstream
027ecf0a379bcc1d09956d46d12d44a3ad9cee14, using an isolated Python 3.11 environment installed withuv(editable core/ext/test-utils, HTTP tool dependencies, and local test server dependencies):date,datetime, orUUID.python -m pytest python/packages/autogen-ext/tests/tools/http/test_http_tool.py -k 'not invalid_request' -q: 23 passed, 1 deselected after the fix.test_invalid_requestexpects hostfaketo raise a connection error, but it receives a response in this environment. Restoring the upstream implementation and running that test alone reproduces the same failure. Removing proxy environment variables also did not resolve it; no change to that test is included here.--config-file python/pyproject.toml --follow-imports=silenton both changed files: passed.git diff --check: passed.Full workspace checks and documentation builds were not run.
Checks
Prepared with Codex assistance.