Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,13 @@ public EventKind onMessageSend(MessageSendParams params, ServerCallContext conte
}
}
}
if (kind instanceof Task taskResult && !taskId.equals(taskResult.getId())) {
throw new InternalError("Task ID mismatch in agent response");
if (kind instanceof Task taskResult) {
if (shouldAddPushInfo(params)) {
pushConfigStore.setInfo(taskResult.getId(), params.configuration().pushNotificationConfig());
}
if (taskId != null && !taskId.equals(taskResult.getId())) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

While adding the taskId != null check prevents a NullPointerException during the comparison, taskId being null (which occurs for new tasks) still poses a significant risk. Specifically, taskId is used as a key for runningAgents (a ConcurrentHashMap) at lines 242, 256, and 342. Since ConcurrentHashMap does not allow null keys, these operations will throw a NullPointerException before this line is even reached. Consider ensuring a non-null task ID is available (e.g., by generating a temporary one) before interacting with runningAgents.

throw new InternalError("Task ID mismatch in agent response");
}
}

// Send push notification after initial return (for both blocking and non-blocking)
Expand Down
4 changes: 4 additions & 0 deletions spec/src/main/java/io/a2a/spec/AgentCapabilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
public record AgentCapabilities(boolean streaming, boolean pushNotifications, boolean stateTransitionHistory,
List<AgentExtension> extensions) {

public AgentCapabilities {
extensions = extensions == null ? List.of() : extensions;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Using List.copyOf is preferred here to ensure the extensions list is unmodifiable and to provide a defensive copy if a mutable list was passed to the constructor. This maintains the immutability of the record and aligns with the pattern used in other classes like Task.

Suggested change
extensions = extensions == null ? List.of() : extensions;
extensions = extensions == null ? List.of() : List.copyOf(extensions);

}

public static class Builder {

private boolean streaming;
Expand Down
Loading