Skip to content

Commit 24772ec

Browse files
committed
Remove JSONRPCError, and repurpose A2AError
1 parent 21abce2 commit 24772ec

File tree

57 files changed

+303
-354
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+303
-354
lines changed

client/transport/jsonrpc/src/main/java/io/a2a/client/transport/jsonrpc/JSONRPCTransport.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import io.a2a.internal.wrappers.GetTaskPushNotificationConfigResponse;
4040
import io.a2a.internal.wrappers.GetTaskRequest;
4141
import io.a2a.internal.wrappers.GetTaskResponse;
42-
import io.a2a.spec.JSONRPCError;
42+
import io.a2a.spec.A2AError;
4343
import io.a2a.internal.wrappers.A2AMessage;
4444
import io.a2a.internal.wrappers.A2AResponse;
4545
import io.a2a.spec.ListTaskPushNotificationConfigParams;
@@ -383,7 +383,7 @@ private A2AHttpClient.PostBuilder createPostBuilder(String url, PayloadAndHeader
383383
private <T extends A2AResponse<?>> T unmarshalResponse(String response, String method)
384384
throws A2AClientException, JsonProcessingException {
385385
A2AResponse<?> value = JSONRPCUtils.parseResponseBody(response, method);
386-
JSONRPCError error = value.getError();
386+
A2AError error = value.getError();
387387
if (error != null) {
388388
throw new A2AClientException(error.getMessage() + (error.getData() != null ? ": " + error.getData() : ""), error);
389389
}

client/transport/jsonrpc/src/main/java/io/a2a/client/transport/jsonrpc/sse/SSEEventListener.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package io.a2a.client.transport.jsonrpc.sse;
22

33
import io.a2a.internal.json.JsonProcessingException;
4-
import io.a2a.spec.JSONRPCError;
4+
import io.a2a.spec.A2AError;
55
import io.a2a.spec.StreamingEventKind;
66
import io.a2a.spec.TaskStatusUpdateEvent;
77

@@ -70,7 +70,7 @@ private void handleMessage(String message, @Nullable Future<Void> future) {
7070
future.cancel(true); // close SSE channel
7171
}
7272
}
73-
} catch (JSONRPCError error) {
73+
} catch (A2AError error) {
7474
if (errorHandler != null) {
7575
errorHandler.accept(error);
7676
}

client/transport/jsonrpc/src/test/java/io/a2a/client/transport/jsonrpc/sse/SSEEventListenerTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import io.a2a.client.transport.jsonrpc.JsonStreamingMessages;
1717
import io.a2a.spec.Artifact;
18-
import io.a2a.spec.JSONRPCError;
18+
import io.a2a.spec.A2AError;
1919
import io.a2a.spec.Message;
2020
import io.a2a.spec.Part;
2121
import io.a2a.spec.StreamingEventKind;
@@ -158,8 +158,8 @@ public void testOnEventWithError() throws Exception {
158158

159159
// Verify the error was processed correctly
160160
assertNotNull(receivedError.get());
161-
assertInstanceOf(JSONRPCError.class, receivedError.get());
162-
JSONRPCError jsonrpcError = (JSONRPCError) receivedError.get();
161+
assertInstanceOf(A2AError.class, receivedError.get());
162+
A2AError jsonrpcError = (A2AError) receivedError.get();
163163
assertEquals(-32602, jsonrpcError.getCode());
164164
assertEquals("Invalid parameters", jsonrpcError.getMessage());
165165
assertEquals("\"Missing required field\"", jsonrpcError.getData());

examples/cloud-deployment/server/src/main/java/io/a2a/examples/cloud/CloudAgentExecutorProducer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import io.a2a.server.events.EventQueue;
66
import io.a2a.server.tasks.TaskUpdater;
77
import io.a2a.spec.InternalError;
8-
import io.a2a.spec.JSONRPCError;
8+
import io.a2a.spec.A2AError;
99
import io.a2a.spec.Message;
1010
import io.a2a.spec.Part;
1111
import io.a2a.spec.TextPart;
@@ -45,7 +45,7 @@ public AgentExecutor agentExecutor() {
4545
private static class CloudAgentExecutor implements AgentExecutor {
4646

4747
@Override
48-
public void execute(RequestContext context, EventQueue eventQueue) throws JSONRPCError {
48+
public void execute(RequestContext context, EventQueue eventQueue) throws A2AError {
4949
TaskUpdater updater = new TaskUpdater(context, eventQueue);
5050

5151
try {
@@ -98,7 +98,7 @@ public void execute(RequestContext context, EventQueue eventQueue) throws JSONRP
9898
LOGGER.info("Artifact added on pod: {}", podName);
9999
}
100100

101-
} catch (JSONRPCError e) {
101+
} catch (A2AError e) {
102102
LOGGER.error("JSONRPC error processing task", e);
103103
throw e;
104104
} catch (Exception e) {
@@ -108,7 +108,7 @@ public void execute(RequestContext context, EventQueue eventQueue) throws JSONRP
108108
}
109109

110110
@Override
111-
public void cancel(RequestContext context, EventQueue eventQueue) throws JSONRPCError {
111+
public void cancel(RequestContext context, EventQueue eventQueue) throws A2AError {
112112
LOGGER.info("Task cancellation requested");
113113
TaskUpdater updater = new TaskUpdater(context, eventQueue);
114114
updater.cancel();

examples/helloworld/server/src/main/java/io/a2a/examples/helloworld/AgentExecutorProducer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import io.a2a.server.agentexecution.RequestContext;
88
import io.a2a.server.events.EventQueue;
99
import io.a2a.A2A;
10-
import io.a2a.spec.JSONRPCError;
10+
import io.a2a.spec.A2AError;
1111
import io.a2a.spec.UnsupportedOperationError;
1212

1313
@ApplicationScoped
@@ -17,12 +17,12 @@ public class AgentExecutorProducer {
1717
public AgentExecutor agentExecutor() {
1818
return new AgentExecutor() {
1919
@Override
20-
public void execute(RequestContext context, EventQueue eventQueue) throws JSONRPCError {
20+
public void execute(RequestContext context, EventQueue eventQueue) throws A2AError {
2121
eventQueue.enqueueEvent(A2A.toAgentMessage("Hello World"));
2222
}
2323

2424
@Override
25-
public void cancel(RequestContext context, EventQueue eventQueue) throws JSONRPCError {
25+
public void cancel(RequestContext context, EventQueue eventQueue) throws A2AError {
2626
throw new UnsupportedOperationError();
2727
}
2828
};

extras/push-notification-config-store-database-jpa/src/test/java/io/a2a/extras/pushnotificationconfigstore/database/jpa/JpaDatabasePushNotificationConfigStoreTestAgentExecutor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import io.a2a.server.tasks.PushNotificationSender;
1313
import io.a2a.server.tasks.TaskUpdater;
1414
import io.a2a.spec.InvalidRequestError;
15-
import io.a2a.spec.JSONRPCError;
15+
import io.a2a.spec.A2AError;
1616
import io.a2a.spec.Message;
1717
import io.a2a.spec.Part;
1818
import io.a2a.spec.TextPart;
@@ -33,7 +33,7 @@ public class JpaDatabasePushNotificationConfigStoreTestAgentExecutor {
3333
public AgentExecutor agentExecutor() {
3434
return new AgentExecutor() {
3535
@Override
36-
public void execute(RequestContext context, EventQueue eventQueue) throws JSONRPCError {
36+
public void execute(RequestContext context, EventQueue eventQueue) throws A2AError {
3737
TaskUpdater taskUpdater = new TaskUpdater(context, eventQueue);
3838
String command = getLastTextPart(context.getMessage());
3939

@@ -55,14 +55,14 @@ public void execute(RequestContext context, EventQueue eventQueue) throws JSONRP
5555
}
5656

5757
@Override
58-
public void cancel(RequestContext context, EventQueue eventQueue) throws JSONRPCError {
58+
public void cancel(RequestContext context, EventQueue eventQueue) throws A2AError {
5959
TaskUpdater taskUpdater = new TaskUpdater(context, eventQueue);
6060
taskUpdater.cancel();
6161
}
6262
};
6363
}
6464

65-
private String getLastTextPart(Message message) throws JSONRPCError {
65+
private String getLastTextPart(Message message) throws A2AError {
6666
if (message.parts() == null || message.parts().isEmpty()) {
6767
return "";
6868
}

extras/queue-manager-replicated/core/src/main/java/io/a2a/extras/queuemanager/replicated/core/ReplicatedEventQueueItem.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import io.a2a.server.events.EventQueueItem;
99
import io.a2a.spec.Event;
10-
import io.a2a.spec.JSONRPCError;
10+
import io.a2a.spec.A2AError;
1111
import io.a2a.spec.StreamingEventKind;
1212

1313
public class ReplicatedEventQueueItem implements EventQueueItem {
@@ -17,7 +17,7 @@ public class ReplicatedEventQueueItem implements EventQueueItem {
1717
private StreamingEventKind event;
1818

1919
@JsonInclude(JsonInclude.Include.NON_NULL)
20-
private JSONRPCError error;
20+
private A2AError error;
2121

2222
private boolean closedEvent;
2323

@@ -32,8 +32,8 @@ public ReplicatedEventQueueItem(String taskId, StreamingEventKind event) {
3232
this.error = null;
3333
}
3434

35-
// Constructor for creating from A2A JSONRPCError objects
36-
public ReplicatedEventQueueItem(String taskId, JSONRPCError error) {
35+
// Constructor for creating from A2A A2AError objects
36+
public ReplicatedEventQueueItem(String taskId, A2AError error) {
3737
this.taskId = taskId;
3838
this.event = null;
3939
this.error = error;
@@ -50,12 +50,12 @@ public ReplicatedEventQueueItem(String taskId, Event event) {
5050
this.event = streamingEvent;
5151
this.error = null;
5252
this.closedEvent = false;
53-
} else if (event instanceof JSONRPCError jsonRpcError) {
53+
} else if (event instanceof A2AError jsonRpcError) {
5454
this.event = null;
5555
this.error = jsonRpcError;
5656
this.closedEvent = false;
5757
} else {
58-
throw new IllegalArgumentException("Event must be StreamingEventKind, JSONRPCError, or QueueClosedEvent, got: " + event.getClass());
58+
throw new IllegalArgumentException("Event must be StreamingEventKind, A2AError, or QueueClosedEvent, got: " + event.getClass());
5959
}
6060
}
6161

@@ -85,25 +85,25 @@ public void setEvent(StreamingEventKind event) {
8585
}
8686

8787
/**
88-
* Get the JSONRPCError field (for JSON serialization).
89-
* @return the JSONRPCError or null
88+
* Get the A2AError field (for JSON serialization).
89+
* @return the A2AError or null
9090
*/
9191
@JsonGetter("error")
9292
@JsonInclude(JsonInclude.Include.NON_NULL)
93-
public JSONRPCError getErrorObject() {
93+
public A2AError getErrorObject() {
9494
return error;
9595
}
9696

9797
@JsonSetter("error")
98-
public void setError(JSONRPCError error) {
98+
public void setError(A2AError error) {
9999
this.error = error;
100100
this.event = null; // Clear event when setting error
101101
}
102102

103103
/**
104104
* Get the contained event as the generic Event interface (implements EventQueueItem).
105105
* This is the method required by the EventQueueItem interface.
106-
* @return the event (StreamingEventKind, JSONRPCError, or QueueClosedEvent) or null if none is set
106+
* @return the event (StreamingEventKind, A2AError, or QueueClosedEvent) or null if none is set
107107
*/
108108
@JsonIgnore
109109
@Override
@@ -137,7 +137,7 @@ public boolean hasEvent() {
137137

138138
/**
139139
* Check if this ReplicatedEvent contains an error.
140-
* @return true if it contains a JSONRPCError
140+
* @return true if it contains a A2AError
141141
*/
142142
public boolean hasError() {
143143
return error != null;

extras/queue-manager-replicated/core/src/test/java/io/a2a/extras/queuemanager/replicated/core/EventSerializationTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import io.a2a.spec.InvalidParamsError;
1818
import io.a2a.spec.InvalidRequestError;
1919
import io.a2a.spec.JSONParseError;
20-
import io.a2a.spec.JSONRPCError;
20+
import io.a2a.spec.A2AError;
2121
import io.a2a.spec.Message;
2222
import io.a2a.spec.MethodNotFoundError;
2323
import io.a2a.spec.Part;
@@ -37,7 +37,7 @@
3737

3838
/**
3939
* Comprehensive test for serialization/deserialization of all StreamingEventKind classes
40-
* and JSONRPCError subclasses to ensure proper type handling in replication.
40+
* and A2AError subclasses to ensure proper type handling in replication.
4141
*/
4242
public class EventSerializationTest {
4343

@@ -169,9 +169,9 @@ public void testTaskArtifactUpdateEventSerialization() throws JsonProcessingExce
169169
}
170170

171171
@Test
172-
public void testJSONRPCErrorSubclassesSerialization() throws JsonProcessingException {
173-
// Test various JSONRPCError subclasses
174-
JSONRPCError[] errors = {
172+
public void testA2AErrorSubclassesSerialization() throws JsonProcessingException {
173+
// Test various A2AError subclasses
174+
A2AError[] errors = {
175175
new InvalidRequestError("Invalid request"),
176176
new MethodNotFoundError(),
177177
new InvalidParamsError("Invalid params"),
@@ -184,13 +184,13 @@ public void testJSONRPCErrorSubclassesSerialization() throws JsonProcessingExcep
184184
// Note: ContentTypeNotSupportedError and InvalidAgentResponseError need specific constructor parameters
185185
};
186186

187-
for (JSONRPCError originalError : errors) {
187+
for (A2AError originalError : errors) {
188188
// Test serialization
189189
String json = JsonUtil.toJson(originalError);
190190
assertTrue(json.contains("\"message\""), "JSON should contain error message for " + originalError.getClass().getSimpleName());
191191

192-
// Test deserialization - it's acceptable to deserialize as base JSONRPCError
193-
JSONRPCError deserializedError = JsonUtil.fromJson(json, JSONRPCError.class);
192+
// Test deserialization - it's acceptable to deserialize as base A2AError
193+
A2AError deserializedError = JsonUtil.fromJson(json, A2AError.class);
194194
assertNotNull(deserializedError, "Should deserialize successfully for " + originalError.getClass().getSimpleName());
195195
assertEquals(originalError.getMessage(), deserializedError.getMessage(), "Error message should match for " + originalError.getClass().getSimpleName());
196196
assertEquals(originalError.getCode(), deserializedError.getCode(), "Error code should match for " + originalError.getClass().getSimpleName());
@@ -243,10 +243,10 @@ public void testReplicatedEventWithStreamingEventSerialization() throws JsonProc
243243

244244
@Test
245245
public void testReplicatedEventWithErrorSerialization() throws JsonProcessingException {
246-
// Test that ReplicatedEventQueueItem can properly handle JSONRPCError
246+
// Test that ReplicatedEventQueueItem can properly handle A2AError
247247
InvalidRequestError error = new InvalidRequestError("Invalid request for testing");
248248

249-
// Create ReplicatedEventQueueItem with JSONRPCError
249+
// Create ReplicatedEventQueueItem with A2AError
250250
ReplicatedEventQueueItem originalReplicatedEvent = new ReplicatedEventQueueItem("error-test-task", error);
251251

252252
// Serialize the ReplicatedEventQueueItemQueueItem
@@ -261,7 +261,7 @@ public void testReplicatedEventWithErrorSerialization() throws JsonProcessingExc
261261
assertEquals(originalReplicatedEvent.getTaskId(), deserializedReplicatedEvent.getTaskId());
262262

263263
// Should get the error back
264-
JSONRPCError retrievedError = deserializedReplicatedEvent.getErrorObject();
264+
A2AError retrievedError = deserializedReplicatedEvent.getErrorObject();
265265
assertNotNull(retrievedError);
266266
assertEquals(error.getMessage(), retrievedError.getMessage());
267267
assertEquals(error.getCode(), retrievedError.getCode());

extras/queue-manager-replicated/tests-multi-instance/quarkus-common/src/main/java/io/a2a/extras/queuemanager/replicated/tests/multiinstance/common/MultiInstanceReplicationAgentExecutor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import io.a2a.server.agentexecution.RequestContext;
55
import io.a2a.server.events.EventQueue;
66
import io.a2a.server.tasks.TaskUpdater;
7-
import io.a2a.spec.JSONRPCError;
7+
import io.a2a.spec.A2AError;
88
import io.a2a.spec.Task;
99
import io.a2a.spec.TextPart;
1010

@@ -18,7 +18,7 @@
1818
*/
1919
public class MultiInstanceReplicationAgentExecutor implements AgentExecutor {
2020
@Override
21-
public void execute(RequestContext context, EventQueue eventQueue) throws JSONRPCError {
21+
public void execute(RequestContext context, EventQueue eventQueue) throws A2AError {
2222
Task task = context.getTask();
2323
TaskUpdater updater = new TaskUpdater(context, eventQueue);
2424

@@ -41,7 +41,7 @@ public void execute(RequestContext context, EventQueue eventQueue) throws JSONRP
4141
}
4242

4343
@Override
44-
public void cancel(RequestContext context, EventQueue eventQueue) throws JSONRPCError {
44+
public void cancel(RequestContext context, EventQueue eventQueue) throws A2AError {
4545
TaskUpdater updater = new TaskUpdater(context, eventQueue);
4646
updater.cancel();
4747
}

extras/queue-manager-replicated/tests-single-instance/src/test/java/io/a2a/extras/queuemanager/replicated/tests/ReplicationTestAgentExecutor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import io.a2a.server.events.EventQueue;
1111
import io.a2a.server.tasks.TaskUpdater;
1212
import io.a2a.spec.InvalidRequestError;
13-
import io.a2a.spec.JSONRPCError;
13+
import io.a2a.spec.A2AError;
1414
import io.a2a.spec.Message;
1515
import io.a2a.spec.Part;
1616
import io.a2a.spec.TextPart;
@@ -28,7 +28,7 @@ public class ReplicationTestAgentExecutor {
2828
public AgentExecutor agentExecutor() {
2929
return new AgentExecutor() {
3030
@Override
31-
public void execute(RequestContext context, EventQueue eventQueue) throws JSONRPCError {
31+
public void execute(RequestContext context, EventQueue eventQueue) throws A2AError {
3232

3333
TaskUpdater taskUpdater = new TaskUpdater(context, eventQueue);
3434
String lastText = getLastTextPart(context.getMessage());
@@ -56,14 +56,14 @@ public void execute(RequestContext context, EventQueue eventQueue) throws JSONRP
5656
}
5757

5858
@Override
59-
public void cancel(RequestContext context, EventQueue eventQueue) throws JSONRPCError {
59+
public void cancel(RequestContext context, EventQueue eventQueue) throws A2AError {
6060
TaskUpdater taskUpdater = new TaskUpdater(context, eventQueue);
6161
taskUpdater.cancel();
6262
}
6363
};
6464
}
6565

66-
private String getLastTextPart(Message message) throws JSONRPCError {
66+
private String getLastTextPart(Message message) throws A2AError {
6767
if (message.parts().isEmpty()) {
6868
throw new InvalidRequestError("No parts in message");
6969
}

0 commit comments

Comments
 (0)