Repository navigation
fix(client): preserve REST endpoint query parameters - #1488
Harshil-1603 wants to merge 1 commit into
Conversation
🧪 Code Coverage (vs
|
| Base | PR | Delta | |
|---|---|---|---|
| src/a2a/client/transports/http_helpers.py | 93.51% | 93.90% | 🟢 +0.40% |
| src/a2a/client/transports/rest.py | 89.95% | 90.13% | 🟢 +0.18% |
| src/a2a/compat/v0_3/rest_transport.py | 95.78% | 95.88% | 🟢 +0.10% |
| src/a2a/server/cluster/database_event_stream.py | 93.64% | 97.27% | 🟢 +3.64% |
| Total | 93.62% | 93.67% | 🟢 +0.05% |
Generated by coverage-comment.yml
1AbdullahButt
left a comment
There was a problem hiding this comment.
I checked why both halves of the change are needed. With httpx 0.28.1, client.build_request('GET', 'http://a/api/tasks/1?api-version=v1', params={'historyLength': 2}) produces http://a/api/tasks/1?historyLength=2. Passing params replaces the URL's query, and an empty dict drops it too. So fixing the path concatenation alone would still have lost the endpoint query on every GET that has operation params. The merge in get_http_params fixes that. I also ran the two helpers on http://agent?x=1, http://agent/api/?a=1&a=2&r=a/ and http://agent/api/. The path goes before the query, repeated values survive, and an operation key replaces every endpoint value for that key. That looks like the right precedence.
All REST calls go through _execute_request or _send_stream_request, plus the separate DELETE path, and all three are covered in both the v1 and v0.3 transports. The JSON-RPC transports post to self.url unchanged, so they never had this bug.
One related spot is not covered. A2ACardResolver.get_agent_card builds f'{self.base_url}/{path_segment}', so a base URL with a query string has the same path-after-query problem when the card is fetched. That may be out of scope here, but it is the same pattern.
Reviewed with help from Claude Code.
Description
An interface URL such as
https://agent/api?api-version=v1currently produces/api?api-version=v1/message:send: the operation path becomes part of the query value. GET operation parameters can also replace the endpoint query entirely. This prevents REST clients from reaching agents behind gateways that require endpoint query parameters.Build operation URLs from parsed URL components and merge endpoint parameters with operation parameters taking precedence. Apply the same handling to v1 and v0.3 REST, including streaming, subscription and the v1 deletion path. Preserve repeated and blank query values and trailing slashes in query values.
Regression coverage uses real HTTPX and HTTPX2 request serialization through MockTransport for both bindings. It checks SendMessage, GetTask with an overriding historyLength, streaming, subscription, and deletion, with query-bearing endpoints and ordinary endpoint controls.
Validation
git diff --checkpassed.