Skip to content

Commit 76b9a00

Browse files
fix: handle blank push notification config IDs (#1242)
* Fix blank push notification config ID handling * test: exclude optional blank push config id * ci: retrigger pull request checks * fix: address push config ID review feedback
1 parent 4aeac45 commit 76b9a00

3 files changed

Lines changed: 27 additions & 4 deletions

File tree

‎server-common/src/main/java/org/a2aproject/sdk/server/requesthandlers/DefaultRequestHandler.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,6 @@ public TaskPushNotificationConfig onCreateTaskPushNotificationConfig(
12101210
public TaskPushNotificationConfig onGetTaskPushNotificationConfig(
12111211
GetTaskPushNotificationConfigParams params, ServerCallContext context) throws A2AError {
12121212
validateRequiredId(context, "taskId", params.taskId());
1213-
validateRequiredId(context, "id", params.id());
12141213
if (pushConfigStore == null) {
12151214
throw new UnsupportedOperationError();
12161215
}
@@ -1226,8 +1225,9 @@ public TaskPushNotificationConfig onGetTaskPushNotificationConfig(
12261225
}
12271226

12281227
String requestedConfigId = params.id();
1229-
String configId = Assert.isNullOrEmpty(requestedConfigId) ? params.taskId()
1230-
: Assert.checkNotNullParam("requestedConfigId", requestedConfigId);
1228+
String configId = requestedConfigId == null || requestedConfigId.isEmpty()
1229+
? params.taskId()
1230+
: requestedConfigId;
12311231
return getTaskPushNotificationConfig(listTaskPushNotificationConfigsResult, configId);
12321232
}
12331233

‎server-common/src/test/java/org/a2aproject/sdk/server/requesthandlers/DefaultRequestHandlerBuilderAuthorizationTest.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ void tearDown() {
114114
"subscribe, ''", "subscribe, ' '",
115115
"createPush, ''", "createPush, ' '",
116116
"getPush, ''", "getPush, ' '",
117-
"getPushId, ''", "getPushId, ' '",
118117
"listPush, ''", "listPush, ' '",
119118
"deletePush, ''", "deletePush, ' '",
120119
"deletePushId, ''", "deletePushId, ' '"

‎server-common/src/test/java/org/a2aproject/sdk/server/requesthandlers/DefaultRequestHandlerTest.java‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
import org.junit.jupiter.params.ParameterizedTest;
8282
import org.junit.jupiter.params.provider.CsvSource;
8383
import org.junit.jupiter.params.provider.NullAndEmptySource;
84+
import org.junit.jupiter.params.provider.ValueSource;
8485

8586
/**
8687
* Integration tests for DefaultRequestHandler focusing on AUTH_REQUIRED workflow.
@@ -1262,6 +1263,29 @@ void testGetTaskPushNotificationConfigDefaultsMissingIdToTaskId() throws Excepti
12621263
assertEquals("http://example.com/get-default-config-id", result.url());
12631264
}
12641265

1266+
@ParameterizedTest
1267+
@NullAndEmptySource
1268+
void testGetTaskPushNotificationConfigDefaultsMissingIdToTaskIdWithEffectiveCard(String configId)
1269+
throws Exception {
1270+
String taskId = "get-default-config-id-with-card";
1271+
taskStore.save(Task.builder()
1272+
.id(taskId)
1273+
.contextId("ctx-get-default-config-id-with-card")
1274+
.status(new TaskStatus(TaskState.TASK_STATE_WORKING))
1275+
.build(), false);
1276+
requestHandler.onCreateTaskPushNotificationConfig(TaskPushNotificationConfig.builder()
1277+
.taskId(taskId)
1278+
.url("http://example.com/get-default-config-id-with-card")
1279+
.build(), NULL_CONTEXT);
1280+
1281+
TaskPushNotificationConfig result = requestHandler.onGetTaskPushNotificationConfig(
1282+
new GetTaskPushNotificationConfigParams(taskId, configId),
1283+
contextWithEffectiveCard(true));
1284+
1285+
assertEquals(taskId, result.id());
1286+
assertEquals("http://example.com/get-default-config-id-with-card", result.url());
1287+
}
1288+
12651289
/**
12661290
* Verify that onMessageSend stores the protocol version when the request
12671291
* includes a push notification config (new task path).

0 commit comments

Comments
 (0)