Skip to content

Commit 2966450

Browse files
authored
fix: Avoid NPE for gRPC when acceptedOutputModes isn't specified for the client side (#256)
# Description Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [x] Follow the [`CONTRIBUTING` Guide](../CONTRIBUTING.md). - [x] Make your Pull Request title in the <https://www.conventionalcommits.org/> specification. - Important Prefixes for [release-please](https://github.com/googleapis/release-please): - `fix:` which represents bug fixes, and correlates to a [SemVer](https://semver.org/) patch. - `feat:` represents a new feature, and correlates to a SemVer minor. - `feat!:`, or `fix!:`, `refactor!:`, etc., which represent a breaking change (indicated by the `!`) and will result in a SemVer major. - [x] Ensure the tests pass - [x] Appropriate READMEs were updated (if necessary)
1 parent bb31a8e commit 2966450

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

spec-grpc/src/main/java/io/a2a/grpc/utils/ProtoUtils.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,9 @@ private static io.a2a.grpc.AuthenticationInfo authenticationInfo(PushNotificatio
337337

338338
public static io.a2a.grpc.SendMessageConfiguration messageSendConfiguration(MessageSendConfiguration messageSendConfiguration) {
339339
io.a2a.grpc.SendMessageConfiguration.Builder builder = io.a2a.grpc.SendMessageConfiguration.newBuilder();
340-
builder.addAllAcceptedOutputModes(messageSendConfiguration.acceptedOutputModes());
340+
if (messageSendConfiguration.acceptedOutputModes() != null) {
341+
builder.addAllAcceptedOutputModes(messageSendConfiguration.acceptedOutputModes());
342+
}
341343
if (messageSendConfiguration.historyLength() != null) {
342344
builder.setHistoryLength(messageSendConfiguration.historyLength());
343345
}
@@ -772,7 +774,8 @@ private static AgentExtension agentExtension(io.a2a.grpc.AgentExtension agentExt
772774

773775
private static MessageSendConfiguration messageSendConfiguration(io.a2a.grpc.SendMessageConfiguration sendMessageConfiguration) {
774776
return new MessageSendConfiguration(
775-
new ArrayList<>(sendMessageConfiguration.getAcceptedOutputModesList()),
777+
sendMessageConfiguration.getAcceptedOutputModesList().isEmpty() ? null :
778+
new ArrayList<>(sendMessageConfiguration.getAcceptedOutputModesList()),
776779
sendMessageConfiguration.getHistoryLength(),
777780
pushNotification(sendMessageConfiguration.getPushNotification()),
778781
sendMessageConfiguration.getBlocking()

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1314,7 +1314,6 @@ private AgentCard createTestAgentCard() {
13141314
private ClientConfig createClientConfig(boolean streaming) {
13151315
return new ClientConfig.Builder()
13161316
.setStreaming(streaming)
1317-
.setAcceptedOutputModes(List.of("text"))
13181317
.build();
13191318
}
13201319

0 commit comments

Comments
 (0)