Skip to content

fix: allow omitted task push config id - #1092

Open
hutiefang76 wants to merge 1 commit into
a2aproject:mainfrom
hutiefang76:codex/a2a-java-1081-optional-push-config-id
Open

fix: allow omitted task push config id#1092
hutiefang76 wants to merge 1 commit into
a2aproject:mainfrom
hutiefang76:codex/a2a-java-1081-optional-push-config-id

Conversation

@hutiefang76

Copy link
Copy Markdown

Description

Allow TaskPushNotificationConfig to omit its id when a client creates a push notification configuration, matching the A2A specification. The in-memory store now assigns the task ID when the supplied ID is null or empty, preserving its existing defaulting behavior.

Tests

  • mvn -pl spec,server-common -am -Dtest=TaskPushNotificationConfigTest,InMemoryPushNotificationConfigStoreTest -Dsurefire.failIfNoSpecifiedTests=false test

    • TaskPushNotificationConfigTest: 1 passed
    • InMemoryPushNotificationConfigStoreTest: 33 passed
  • Follow the CONTRIBUTING guide

  • Use a conventional commit title

  • Tests pass

  • README changes are not needed for this API-contract correction

Fixes #1081 🦕

@kabir kabir left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hi @hutiefang76 - thank you for the PR 👍

I found a few small issues in the code, but we also need to take JpaDatabasePushNotificationConfigStore into account and make some changes, and test this inline with what you have done here. JpaPushNotificationConfigStoreTest might be the right place.

Also GetTaskPushNotificationConfigParams asserts id non-null despite its Javadoc calling it optional. Might as well fix this since it is related.

public void testSetInfoWithoutConfigId() {
String taskId = "task1";
TaskPushNotificationConfig initialConfig = TaskPushNotificationConfig.builder()
.id("") // No ID set

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please create a new test rather than changing this existing one.

Removing .id("") repurposes this test from the empty-string path to the null path rather than covering both.
The empty-string case is the one production actually hits — the mapper doesn't apply emptyToNull to id, so at runtime a missing id arrives as "", never null.
Recommend keeping the "" case here and adding a separate null-id test (or parameterizing over both), so the load-bearing branch stays asserted.

assertEquals(taskId, configResult.configs().get(0).id());

TaskPushNotificationConfig updatedConfig = TaskPushNotificationConfig.builder()
.id("") // No ID set

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please create a new test rather than changing this existing one.

public TaskPushNotificationConfig setInfo(TaskPushNotificationConfig notificationConfig) {
String taskId = Assert.checkNotNullParam("taskId", notificationConfig.taskId());
TaskPushNotificationConfig.Builder builder = TaskPushNotificationConfig.builder(notificationConfig);
if (notificationConfig.id().isEmpty()) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not a comment about this code, but JpaDatabasePushNotificationConfigStore has the same latent NPE, and needs fixing too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: TaskPushNotificationConfig.id is enforced as required, contradicting the spec where id is optional on create

2 participants