Skip to content

Commit 952bf9d

Browse files
committed
Fix cicd pipeline issues .
1 parent 7bff493 commit 952bf9d

File tree

2 files changed

+19
-29
lines changed

2 files changed

+19
-29
lines changed

client/src/main/java/io/a2a/client/A2ACardResolver.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,13 @@ public A2ACardResolver(A2AHttpClient httpClient, String baseUrl, String agentCar
5656
Map<String, String> authHeaders) throws A2AClientError {
5757
this.httpClient = httpClient;
5858
agentCardPath = agentCardPath == null || agentCardPath.isEmpty() ? DEFAULT_AGENT_CARD_PATH : agentCardPath;
59-
try {
60-
this.url = new URI(baseUrl).resolve(agentCardPath).toString();
61-
} catch (URISyntaxException e) {
62-
throw new A2AClientError("Invalid agent URL", e);
59+
if (baseUrl.endsWith("/")) {
60+
baseUrl = baseUrl.substring(0, baseUrl.length() - 1);
61+
}
62+
if (!agentCardPath.startsWith("/")) {
63+
agentCardPath = "/" + agentCardPath;
6364
}
65+
this.url = baseUrl + agentCardPath;
6466
this.authHeaders = authHeaders;
6567
}
6668

tests/server-common/src/test/java/io/a2a/server/apps/common/AbstractA2AServerTest.java

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,10 @@ private void testGetTask(String mediaType) throws Exception {
153153
public void testGetTaskNotFound() throws Exception {
154154
assertTrue(getTaskFromTaskStore("non-existent-task") == null);
155155
try {
156-
GetTaskResponse response = client.getTask("1", new TaskQueryParams("non-existent-task"));
157-
assertEquals("1", response.getId());
158-
assertInstanceOf(JSONRPCError.class, response.getError());
159-
assertEquals(new TaskNotFoundError().getCode(), response.getError().getCode());
160-
assertNull(response.getResult());
156+
client.getTask("1", new TaskQueryParams("non-existent-task"));
157+
fail("Expected A2AServerException to be thrown");
161158
} catch (A2AServerException e) {
162-
fail("Unexpected exception during getTask for non-existent task: " + e.getMessage(), e);
159+
assertInstanceOf(TaskNotFoundError.class, e.getCause());
163160
}
164161
}
165162

@@ -184,13 +181,10 @@ public void testCancelTaskSuccess() throws Exception {
184181
public void testCancelTaskNotSupported() throws Exception {
185182
saveTaskInTaskStore(CANCEL_TASK_NOT_SUPPORTED);
186183
try {
187-
CancelTaskResponse response = client.cancelTask("1", new TaskIdParams(CANCEL_TASK_NOT_SUPPORTED.getId()));
188-
assertNull(response.getResult());
189-
assertEquals("1", response.getId());
190-
assertInstanceOf(JSONRPCError.class, response.getError());
191-
assertEquals(new UnsupportedOperationError().getCode(), response.getError().getCode());
184+
client.cancelTask("1", new TaskIdParams(CANCEL_TASK_NOT_SUPPORTED.getId()));
185+
fail("Expected A2AServerException to be thrown");
192186
} catch (A2AServerException e) {
193-
fail("Unexpected exception during cancel task not supported test: " + e.getMessage(), e);
187+
assertInstanceOf(UnsupportedOperationError.class, e.getCause());
194188
} finally {
195189
deleteTaskInTaskStore(CANCEL_TASK_NOT_SUPPORTED.getId());
196190
}
@@ -199,13 +193,10 @@ public void testCancelTaskNotSupported() throws Exception {
199193
@Test
200194
public void testCancelTaskNotFound() {
201195
try {
202-
CancelTaskResponse response = client.cancelTask("1", new TaskIdParams("non-existent-task"));
203-
assertEquals("1", response.getId());
204-
assertNull(response.getResult());
205-
assertInstanceOf(JSONRPCError.class, response.getError());
206-
assertEquals(new TaskNotFoundError().getCode(), response.getError().getCode());
196+
client.cancelTask("1", new TaskIdParams("non-existent-task"));
197+
fail("Expected A2AServerException to be thrown");
207198
} catch (A2AServerException e) {
208-
fail("Unexpected exception during cancel task not found test: " + e.getMessage(), e);
199+
assertInstanceOf(TaskNotFoundError.class, e.getCause());
209200
}
210201
}
211202

@@ -315,15 +306,12 @@ public void testError() {
315306
.contextId(SEND_MESSAGE_NOT_SUPPORTED.getContextId())
316307
.build();
317308
MessageSendParams messageSendParams = new MessageSendParams(message, null, null);
318-
309+
319310
try {
320-
SendMessageResponse response = client.sendMessage("1", messageSendParams);
321-
assertEquals("1", response.getId());
322-
assertNull(response.getResult());
323-
assertInstanceOf(JSONRPCError.class, response.getError());
324-
assertEquals(new UnsupportedOperationError().getCode(), response.getError().getCode());
311+
client.sendMessage("1", messageSendParams);
312+
fail("Expected A2AServerException to be thrown");
325313
} catch (A2AServerException e) {
326-
fail("Unexpected exception during error handling test: " + e.getMessage(), e);
314+
assertInstanceOf(UnsupportedOperationError.class, e.getCause());
327315
}
328316
}
329317

0 commit comments

Comments
 (0)