Skip to content

Commit c0fc2e1

Browse files
committed
fix(rest): format history length query parameter for v0.3
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
1 parent 9b0210f commit c0fc2e1

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

‎compat-0.3/client/transport/rest/src/main/java/org/a2aproject/sdk/compat03/client/transport/rest/RestTransport_v0_3.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public Task_v0_3 getTask(TaskQueryParams_v0_3 taskQueryParams, @Nullable ClientC
140140
try {
141141
String url;
142142
if (taskQueryParams.historyLength() > 0) {
143-
url = agentUrl + String.format("/v1/tasks/%1s?historyLength=%2d", taskQueryParams.id(), taskQueryParams.historyLength());
143+
url = agentUrl + String.format("/v1/tasks/%s?historyLength=%d", taskQueryParams.id(), taskQueryParams.historyLength());
144144
} else {
145145
url = agentUrl + String.format("/v1/tasks/%1s", taskQueryParams.id());
146146
}

‎compat-0.3/client/transport/rest/src/test/java/org/a2aproject/sdk/compat03/client/transport/rest/RestTransport_v0_3_Test.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,15 @@ public void testGetTask() throws Exception {
188188
request()
189189
.withMethod("GET")
190190
.withPath("/v1/tasks/de38c76d-d54c-436c-8b9f-4c2703648d64")
191+
.withQueryStringParameter("historyLength", "5")
191192
)
192193
.respond(
193194
response()
194195
.withStatusCode(200)
195196
.withBody(GET_TASK_TEST_RESPONSE)
196197
);
197198
ClientCallContext_v0_3 context = null;
198-
TaskQueryParams_v0_3 request = new TaskQueryParams_v0_3("de38c76d-d54c-436c-8b9f-4c2703648d64", 10);
199+
TaskQueryParams_v0_3 request = new TaskQueryParams_v0_3("de38c76d-d54c-436c-8b9f-4c2703648d64", 5);
199200
RestTransport_v0_3 instance = new RestTransport_v0_3(CARD);
200201
Task_v0_3 task = instance.getTask(request, context);
201202
assertEquals("de38c76d-d54c-436c-8b9f-4c2703648d64", task.id());

0 commit comments

Comments
 (0)