-
Notifications
You must be signed in to change notification settings - Fork 148
fix: Don't autogenerate message id (0.3 TCK has a test for a null one) #899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,5 @@ | ||
| package org.a2aproject.sdk.compat03.spec; | ||
|
|
||
|
|
||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.UUID; | ||
|
|
@@ -14,7 +13,7 @@ | |
| public record Message_v0_3( | ||
| Role role, | ||
| List<Part_v0_3<?>> parts, | ||
| String messageId, | ||
| @Nullable String messageId, | ||
| @Nullable String contextId, | ||
| @Nullable String taskId, | ||
| @Nullable List<String> referenceTaskIds, | ||
|
|
@@ -25,7 +24,7 @@ public record Message_v0_3( | |
|
|
||
| public static final String KIND = "message"; | ||
|
|
||
| public Message_v0_3(Role role, List<Part_v0_3<?>> parts, String messageId, @Nullable String contextId, | ||
| public Message_v0_3(Role role, List<Part_v0_3<?>> parts, @Nullable String messageId, @Nullable String contextId, | ||
| @Nullable String taskId, @Nullable List<String> referenceTaskIds, | ||
| @Nullable Map<String, Object> metadata, @Nullable List<String> extensions, String kind) { | ||
| Assert.checkNotNullParam("role", role); | ||
|
|
@@ -35,7 +34,7 @@ public Message_v0_3(Role role, List<Part_v0_3<?>> parts, String messageId, @Null | |
| throw new IllegalArgumentException("Parts cannot be empty"); | ||
| } | ||
| this.parts = List.copyOf(parts); | ||
| this.messageId = messageId == null ? UUID.randomUUID().toString() : messageId; | ||
| this.messageId = messageId; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Although the record constructor has been updated to allow and preserve a null public Message_v0_3 build() {
return new Message_v0_3(role, parts, messageId == null ? UUID.randomUUID().toString() : messageId,
contextId, taskId, referenceTaskIds, metadata, extensions);
}This makes the builder inconsistent with the record constructor and prevents clients from using the builder to construct a
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gemini-code-assist The record constructor is for internal serialization where a null ID is needed. This is needed since the TCK has a test for null message IDs and we need to be able to to pass this test. The Builder is more client/user API, and the thinking is to steer them towards having to provide a messageId
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for the clarification, kabir. That makes sense given the different requirements for internal serialization versus the public-facing builder API. I understand the design choice to enforce explicit |
||
| this.kind = kind != null ? kind : KIND; | ||
| if (!this.kind.equals(KIND)) { | ||
| throw new IllegalArgumentException("Invalid Message"); | ||
|
|
@@ -47,7 +46,7 @@ public Message_v0_3(Role role, List<Part_v0_3<?>> parts, String messageId, @Null | |
| this.extensions = extensions != null ? List.copyOf(extensions) : null; | ||
| } | ||
|
kabir marked this conversation as resolved.
|
||
|
|
||
| public Message_v0_3(Role role, List<Part_v0_3<?>> parts, String messageId, @Nullable String contextId, | ||
| public Message_v0_3(Role role, List<Part_v0_3<?>> parts, @Nullable String messageId, @Nullable String contextId, | ||
| @Nullable String taskId, @Nullable List<String> referenceTaskIds, | ||
| @Nullable Map<String, Object> metadata, @Nullable List<String> extensions) { | ||
| this(role, parts, messageId, contextId, taskId, referenceTaskIds, metadata, extensions, KIND); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.