Skip to content

fix: distinguish encoded task IDs from REST actions - #559

Open
Linux2010 wants to merge 2 commits into
a2aproject:mainfrom
Linux2010:codex/fix-encoded-task-action-routing
Open

Linux2010 wants to merge 2 commits into
a2aproject:mainfrom
Linux2010:codex/fix-encoded-task-action-routing

Conversation

@Linux2010

@Linux2010 Linux2010 commented Nov 14, 2026 •

Copy link
Copy Markdown

Fixes #564

Summary

The HTTP+JSON router interprets task IDs after URL decoding, so a GET for foo%3Asubscribe subscribes to foo, and a POST to foo%3Acancel can cancel foo instead of treating the encoded colon as part of the ID.

Although DefaultRequestHandler initially allocates a UUIDv7, an AgentExecutor can emit a StreamResponse::Task with a custom Task.id; the handler currently saves that task under the emitted ID and returns it to the caller. A new end-to-end regression exercises an executor returning foo:subscribe and the subsequent encoded GET. Imported task stores and custom handlers are other ways a deployment can expose such IDs.

A shared helper identifies a literal action separator in the raw final path segment, checks the decoded action name, and strips it from the decoded ID. This preserves valid percent-encoded action characters while distinguishing an encoded colon in an ID. Regression coverage also checks operation and ID routing for nested routes, tenant paths, query strings and double encoding.

percent-encoding is now a direct dependency of a2a-server; it was already present in Cargo.lock, so this adds no new locked package.

Validation

  • The new executor-to-GET regression fails against upstream main (404 instead of 200) and passes with this fix.
  • cargo test -p a2a-server-lf --locked --offline (283 unit tests, 8 integration tests and 1 doc test passed, using the local cached registry mirror).
  • cargo clippy -p a2a-server-lf --all-targets --locked --offline -- -D warnings (using the local cached registry mirror).
  • cargo fmt --all -- --check and git diff --check.

@Linux2010
Linux2010 requested a review from a team as a code owner November 14, 2026 05:44
@muscariello

Copy link
Copy Markdown
Member

@Linux2010 can you please create an issue for this ?

@codecov

codecov Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Linux2010
Linux2010 force-pushed the codex/fix-encoded-task-action-routing branch from cc5111b to 651bcd2 Compare November 19, 2026 11:28
Signed-off-by: andy <linux2011@qq.com>
@Linux2010
Linux2010 force-pushed the codex/fix-encoded-task-action-routing branch from 651bcd2 to 5f60e60 Compare November 19, 2026 11:39

@muscariello muscariello 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.

The routing is correct: has_task_action looks at the raw last path segment and treats only a literal :cancel or :subscribe as an action, so foo%3Asubscribe stays an ID. The test table (%3A, mixed case, double encoding, a query string) covers the cases that matter.

  1. No linked issue yet. Please open one with what a client observes today, which request reaches which handler. Task IDs are server-minted UUIDs by default, so this needs an executor that issues IDs with a colon; saying how a deployment gets there shows why it is worth the extra code.
  2. The has_task_action(...) && let Some(..) = ….strip_suffix(…) pair is written three times. One helper that returns the stripped ID would keep the two checks from drifting apart.
  3. percent-encoding becomes a direct dependency of a2a-server. It is already in the lock file, so no new package, but it is worth a line in the description.

The a2a-server suite passes locally on this head, including the new tests.

Signed-off-by: andy <linux2011@qq.com>

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.

HTTP+JSON task routing treats encoded colons in task IDs as action separators

2 participants