Skip to content

fix: Don't autogenerate message id (0.3 TCK has a test for a null one)#899

Open
kabir wants to merge 1 commit into
a2aproject:mainfrom
kabir:jakarta-fixes-3
Open

fix: Don't autogenerate message id (0.3 TCK has a test for a null one)#899
kabir wants to merge 1 commit into
a2aproject:mainfrom
kabir:jakarta-fixes-3

Conversation

@kabir
Copy link
Copy Markdown
Collaborator

@kabir kabir commented May 26, 2026

No description provided.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors several core specification classes in the compat-0.3 module (such as Message_v0_3, Task_v0_3, and various security schemes and parts) from standard classes to Java records. This change updates all getter method invocations to record accessor methods across clients, transports, mappers, and tests. Additionally, a new test infrastructure module tests/server-common is introduced. The review feedback highlights potential NullPointerException risks and validation failures if messageId is null, recommending that messageId be marked as @Nullable in Message_v0_3 and properly null-checked before being set in the protobuf builder in ProtoUtils_v0_3.

@kabir kabir force-pushed the jakarta-fixes-3 branch 2 times, most recently from d448a94 to 8bf74e4 Compare May 28, 2026 07:19
@kabir
Copy link
Copy Markdown
Collaborator Author

kabir commented May 28, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the Message_v0_3 record to allow a null messageId instead of autogenerating a UUID, with corresponding updates to the protobuf utility class and serialization tests. The review feedback highlights two critical inconsistencies: the deserialization logic in FromProto.message still rejects empty message IDs, and the Message_v0_3.Builder.build() method still autogenerates a UUID when the ID is null.

}
this.parts = List.copyOf(parts);
this.messageId = messageId == null ? UUID.randomUUID().toString() : messageId;
this.messageId = messageId;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Although the record constructor has been updated to allow and preserve a null messageId (instead of autogenerating a UUID), the Message_v0_3.Builder.build() method (around line 146) still autogenerates a UUID if messageId is 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 Message_v0_3 with a null messageId. Consider updating the builder to also allow null messageId without autogenerating a UUID.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 messageId provision for clients.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kabir kabir force-pushed the jakarta-fixes-3 branch from 8bf74e4 to fc736e8 Compare May 28, 2026 07:29
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.

1 participant