Skip to content
Merged
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 @@ -5,7 +5,9 @@
import static io.a2a.util.Utils.appendArtifactToTask;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import io.a2a.spec.A2AServerException;
import io.a2a.spec.Artifact;
Expand Down Expand Up @@ -78,7 +80,9 @@ Task saveTaskEvent(TaskStatusUpdateEvent event) throws A2AServerException {

// Handle metadata from the event
if (event.getMetadata() != null) {
builder.metadata(event.getMetadata());
Map<String, Object> metadata = task.getMetadata() == null ? new HashMap<>() : new HashMap<>(task.getMetadata());
metadata.putAll(event.getMetadata());
builder.metadata(metadata);
}

task = builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,8 @@ public void testSaveTaskEventMetadataUpdateNull() throws A2AServerException {
}

@Test
public void testSaveTaskEventMetadataUpdateOverwritesExisting() throws A2AServerException {
// Test that metadata update overwrites existing metadata
public void testSaveTaskEventMetadataMergeExisting() throws A2AServerException {
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

While the test method name has been correctly updated to reflect the new merging logic, the comment on the following line (592) is now outdated and misleading, as it still refers to overwriting metadata. To improve clarity and prevent confusion, please update the comment to align with the test's new purpose.

For example:

// Test that metadata update merges with existing metadata

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi @flex-myeonghyeon Thank you for your PR! Would you be able to update this method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kabir
I’ve updated the comment.
Thank you.

// Test that metadata update merges with existing metadata
Map<String, Object> originalMetadata = new HashMap<>();
originalMetadata.put("original_key", "original_value");

Expand All @@ -612,8 +612,10 @@ public void testSaveTaskEventMetadataUpdateOverwritesExisting() throws A2AServer
taskManager.saveTaskEvent(event);

Task updatedTask = taskManager.getTask();
assertEquals(newMetadata, updatedTask.getMetadata());
assertNotEquals(originalMetadata, updatedTask.getMetadata());

Map<String, Object> mergedMetadata = new HashMap<>(originalMetadata);
mergedMetadata.putAll(newMetadata);
assertEquals(mergedMetadata, updatedTask.getMetadata());
}

@Test
Expand Down