Skip to content

fix(client): preserve REST endpoint query parameters - #1488

Open
Harshil-1603 wants to merge 1 commit into
a2aproject:mainfrom
Harshil-1603:fix/rest-endpoint-queries
Open

Harshil-1603 wants to merge 1 commit into
a2aproject:mainfrom
Harshil-1603:fix/rest-endpoint-queries

Conversation

@Harshil-1603

Copy link
Copy Markdown
Contributor

Description

An interface URL such as https://agent/api?api-version=v1 currently 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

  • All four query-bearing combinations fail against the original implementation; eight ordinary-endpoint controls pass.
  • All 12 endpoint tests pass after the fix.
  • Repository lint/format/type-check script passed (four existing type-ignore warnings).
  • Full suite and the required coverage run both passed: 2,637 passed, 215 skipped, 4 expected failures and 1 pre-existing non-strict unexpected pass.
  • git diff --check passed.
  • Coverage report: 94% overall (repository minimum:88%).

@Harshil-1603
Harshil-1603 requested a review from a team as a code owner November 17, 2026 16:28
@github-actions

Copy link
Copy Markdown

🧪 Code Coverage (vs main)

⬇️ Download Full Report

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 1AbdullahButt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants