Skip to content

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

Open

Description

@Linux2010

Problem

The HTTP+JSON router selects task operations after decoding the final path segment. A percent-encoded colon that belongs to a task ID can therefore be mistaken for the literal separator before an action suffix, causing the request to reach a handler for a different task.

How a task ID containing a colon can arise

DefaultRequestHandler normally creates a UUIDv7 before invoking the executor. However, an AgentExecutor can emit a StreamResponse::Task containing its own Task.id; the current handler persists that task under the emitted ID and returns it to the caller. For example, an executor returning a completed task with ID foo:subscribe produces a task addressable by that ID. Tasks imported into a custom TaskStore or served by a custom RequestHandler can also have such IDs.

Reproduction

  1. Have an executor emit a task snapshot with ID foo:subscribe in response to POST /message:send; the response contains that ID.
  2. Send GET /tasks/foo%3Asubscribe to retrieve it.
  3. Separately, if a task foo exists, send POST /tasks/foo%3Acancel.

Expected behavior

An encoded colon is part of the task ID. The GET should invoke get_task for foo:subscribe; the POST without a literal action separator should be rejected as an unsupported task action and must not cancel foo.

Actual behavior on the unfixed main branch

The GET is dispatched to subscribe_to_task for foo rather than get_task for foo:subscribe. In a reproduction using the default handler and the executor above, the GET returns 404 even though the returned task exists. The POST is dispatched to cancel_task for foo, potentially cancelling a different task.

Proposed fix and regression coverage

Identify action separators in the raw final path segment before operating on the decoded ID. Existing PR: #559. Its tests cover nested routes, tenant paths, query strings, double encoding, and a task snapshot emitted by a custom executor.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions