Skip to content

fix(compat): percent-encode ids in v0.3 REST transport paths - #1458

Merged
Iwaniukooo11 merged 2 commits into
a2aproject:mainfrom
1AbdullahButt:fix/compat-rest-quote-ids
Nov 13, 2026
Merged

Iwaniukooo11 merged 2 commits into
a2aproject:mainfrom
1AbdullahButt:fix/compat-rest-quote-ids

Conversation

@1AbdullahButt

Copy link
Copy Markdown
Contributor

Description

CompatRestTransport (the v0.3 REST client) put task ids and push notification config ids into URL paths as raw text. An id containing #, ? or % then reached a different resource: getting the push config alerts#ops returned the config alerts, and get_task('t1?x') returned task t1. #1436 fixed this for RestTransport; the v0.3 client was not covered.

This PR encodes each id with urllib.parse.quote(value, safe=''), the same helper RestTransport uses, at the six path sites (get_task, cancel_task, subscribe, and push config create, get and list). Ids without reserved characters produce the same URL as before.

Tests: TestCompatRestTransportPathEncoding in tests/compat/v0_3/test_rest_transport.py runs a real DefaultRequestHandler behind create_rest_routes(..., enable_v0_3_compat=True) through httpx.ASGITransport. One test creates alerts and alerts#ops and checks that getting alerts#ops returns that config. The other checks that get_task('t1?x') does not return task t1.

$ pytest tests/compat/v0_3/test_rest_transport.py -k PathEncoding   # rest_transport.py from main
2 failed, 35 deselected
$ pytest tests/compat/v0_3/test_rest_transport.py -k PathEncoding   # this branch
2 passed, 35 deselected
$ pytest tests/compat tests/client
595 passed

ruff check, ruff format and ty check pass on the changed files.

This change was written with Claude Code.

Fixes #1457 🦕

🤖 Generated with Claude Code

CompatRestTransport put task ids and push notification config ids into
URL paths as raw text, so an id containing '#', '?' or '%' reached a
different resource: getting the push config 'alerts#ops' returned the
config 'alerts', and get_task('t1?x') returned task 't1'.

Encode each id with urllib.parse.quote(safe='') as RestTransport does
since a2aproject#1436.

Fixes a2aproject#1457

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@1AbdullahButt
1AbdullahButt requested a review from a team as a code owner November 12, 2026 19:37
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

🧪 Code Coverage (vs main)

⬇️ Download Full Report

Base PR Delta
src/a2a/compat/v0_3/rest_transport.py 95.73% 95.78% 🟢 +0.05%
src/a2a/server/request_handlers/default_request_handler_v2.py 88.34% 88.60% 🟢 +0.26%
Total 93.59% 93.60% 🟢 +0.01%

Generated by coverage-comment.yml

@Iwaniukooo11 Iwaniukooo11 self-assigned this Nov 13, 2026

@Iwaniukooo11 Iwaniukooo11 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@Iwaniukooo11
Iwaniukooo11 merged commit 1ff86d5 into a2aproject:main Nov 13, 2026
17 checks passed
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.

[Bug]: v0.3 REST client puts raw task and push config ids in URL paths, so ids with # or ? read the wrong resource

2 participants