Skip to content

fix(rest): format single-digit history length query - #1200

Merged
kabir merged 2 commits into
a2aproject:mainfrom
014-code:1197-rest-history-length-url
Oct 6, 2026
Merged

kabir merged 2 commits into
a2aproject:mainfrom
014-code:1197-rest-history-length-url

Conversation

@014-code

@014-code 014-code commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

What

Fix REST getTask URL formatting for single-digit historyLength values.

Why

The %2d format specifier pads single-digit values with a leading space, producing an invalid query parameter such as historyLength= 5.

Validation

  • RestTransportTest: 12 tests passed
  • Maven build completed successfully

Fixes #1197

@kabir kabir left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the fix @014-code ! The change looks good, and the updated test catches the single-digit case nicely.

Could you also apply the same fix and regression test to RestTransport_v0_3? Its getTask method still uses %2d, so history lengths of 1–9 fail there too. Since #1197 covers both protocol versions, that would fully address the issue.

Apply the same single-digit formatting fix to RestTransport_v0_3, whose getTask still used %2d and padded single-digit history lengths with a leading space, producing an invalid query parameter such as historyLength= 5. Add a regression test using a single-digit history length.

This fixes a2aproject#1197
@014-code
014-code force-pushed the 1197-rest-history-length-url branch from 91ce7a3 to c0fc2e1 Compare October 6, 2026 05:47
@014-code

014-code commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @kabir! Applied the same fix to RestTransport_v0_3.getTask — it was still using %2d, so the single-digit case was broken there too:

url = agentUrl + String.format("/v1/tasks/%s?historyLength=%d", taskQueryParams.id(), taskQueryParams.historyLength());

Added the matching regression test in RestTransport_v0_3_Test.testGetTask (history length 5 plus withQueryStringParameter("historyLength", "5")), mirroring the v1 test.

Validation:

  • RestTransport_v0_3_Test: 9 tests passed
  • Reverting the fix locally makes testGetTask fail with IllegalArgumentException: Illegal character in query at index 82: http://localhost:4001/v1/tasks/de38c76d-...?historyLength= 5, so the test does catch the single-digit case
  • RestTransportTest (v1): 14 tests passed

Also rebased the branch onto current main, so both protocol versions are covered on top of the latest code.

@kabir kabir left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The v0.3 transport now uses unpadded decimal formatting for historyLength, and its regression test checks the single-digit query parameter. The v1 path and test cover the same case. The diff addresses the outstanding feedback; CI checks are passing.

@kabir
kabir merged commit ceb924f into a2aproject:main Oct 6, 2026
14 checks passed
@kabir

kabir commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

THanks @014-code !

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]: REST transport: getTask builds an invalid URL for single-digit historyLength

2 participants