Skip to content

fix(taskstore): make page tokens unambiguous for task IDs containing underscores - #402

Open
ez-lbz wants to merge 2 commits into
a2aproject:mainfrom
ez-lbz:fix/page-token-separator
Open

fix(taskstore): make page tokens unambiguous for task IDs containing underscores#402
ez-lbz wants to merge 2 commits into
a2aproject:mainfrom
ez-lbz:fix/page-token-separator

Conversation

@ez-lbz

@ez-lbz ez-lbz commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

What changed

1. Make task page tokens unambiguous for IDs containing underscores

Problem:

Page tokens were encoded as <time>_<taskID> and decoded with strings.Split(decoded, "_"). The task ID is client-controlled and may itself contain _, so such tokens produced more than two parts and pagination broke for those tasks.

Fix (a2asrv/taskstore/inmemory.go, a2asrv/taskstore/store_test.go):

  • New token format <time>_<length>_<taskID>, where <length> is the byte length of the task ID; decoding uses SplitN(_, 3) plus a length check.
  • Legacy <time>_<taskID> tokens are still accepted for backward compatibility.
  • Corrupted length prefixes are rejected with a2a.ErrParseError.
  • Added TestInMemoryTaskStore_List_PageTokenWithUnderscoreIDs and TestPageTokenRoundTrip.

Testing

  • go test ./a2asrv/... ./internal/... — all pass.
  • New tests cover underscore IDs (single and double), legacy-token decoding, and corrupted length-prefix rejection.

Behavior change: the token format is now <time>_<length>_<taskID>; tokens produced by older versions still decode.

ez-lbz added 2 commits August 11, 2026 00:20
…underscores

Page tokens were encoded as "<time>_<taskID>" and decoded by splitting
on "_"; a client-supplied task ID containing "_" produced more than
two parts and the token failed to decode, breaking pagination. Encode
the token as "<time>_<length>_<taskID>" with the ID length prefix so
fields can be split unambiguously; the decoder still accepts legacy
tokens (two parts) for backward compatibility and rejects corrupted
length prefixes. Add regression tests for underscore IDs, legacy tokens
and corrupted prefixes.
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.

1 participant