Skip to content

fix!: Make tenant optional in MessageSendParams#694

Closed
CokeLee777 wants to merge 1 commit intoa2aproject:mainfrom
CokeLee777:issue-693
Closed

fix!: Make tenant optional in MessageSendParams#694
CokeLee777 wants to merge 1 commit intoa2aproject:mainfrom
CokeLee777:issue-693

Conversation

@CokeLee777
Copy link
Contributor

@CokeLee777 CokeLee777 commented Mar 1, 2026

Description

The tenant field in MessageSendParams was previously required and validated as non-null in the compact constructor, which forced callers to always provide a tenant even when it is not applicable.

This change makes tenant truly optional:

  • Remove Assert.checkNotNullParam("tenant", tenant) from the compact
    constructor so that null values are accepted at construction time
  • Annotate the tenant record component with @Nullable to clearly
    signal that null may be passed by callers
  • Normalize null tenant to an empty string in the compact constructor,
    which is the single point of normalization for all construction paths
  • Update Builder.tenant() to accept a @Nullable String so that
    callers can explicitly pass null without a type violation
  • Simplify Builder.build() to pass tenant directly, delegating
    normalization to the compact constructor

Javadoc is updated across the class to accurately reflect the optional nature, default value, and normalization behavior of tenant.

Fixes: #693

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the flexibility of the MessageSendParams class by making the tenant field optional. Previously, this field was mandatory, which could lead to unnecessary data provision in scenarios where a tenant identifier was not relevant. The change allows callers to construct MessageSendParams instances without requiring a tenant, simplifying API usage and reducing boilerplate.

Highlights

  • Tenant field nullability: The tenant field in the MessageSendParams record has been updated to be @Nullable, allowing it to be omitted when not applicable.
  • Constructor validation: The null-check for the tenant field has been removed from the compact constructor of MessageSendParams, aligning with its new optional status.
  • Builder method update: The Builder.tenant() method now accepts a @Nullable String for the tenant identifier, providing consistency with the record's definition.
  • Javadoc updates: Javadoc comments have been revised to accurately reflect that the tenant parameter is now optional.
Changelog
  • spec/src/main/java/io/a2a/spec/MessageSendParams.java
    • Made the tenant field nullable in the MessageSendParams record definition.
    • Removed the Assert.checkNotNullParam call for the tenant field in the compact constructor.
    • Updated the tenant parameter in the Builder.tenant() method to be nullable.
    • Adjusted Javadoc for the tenant parameter to indicate it is now optional.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
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 makes the tenant field in MessageSendParams optional. The changes correctly apply the @Nullable annotation, remove the null-check in the constructor, and update the builder method and Javadoc. My review includes a suggestion to ensure consistency in handling null tenants across the class, particularly in the builder and convenience constructor, to fully align with the goal of making the tenant optional.

@CokeLee777
Copy link
Contributor Author

/gemini review

Copy link
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 makes the tenant field in MessageSendParams optional. The changes correctly update the record definition, constructors, and builder to allow a null tenant. However, the compact constructor normalizes a null tenant to an empty string. The feedback suggests reconsidering this normalization to keep the behavior consistent with the @Nullable annotation, which implies that the field can hold a null value. This comment is retained as it does not conflict with any provided rules.

@CokeLee777
Copy link
Contributor Author

/gemini review

Copy link
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 makes the tenant field in MessageSendParams optional, which was previously a required field. The changes involve removing the null-check in the compact constructor, updating the builder to accept a nullable tenant, and normalizing null tenants to an empty string in the convenience constructor and builder. The Javadocs have also been updated to reflect these changes.

My review identifies one area for improvement to ensure the tenant is consistently non-null. I've suggested a change to the compact constructor to handle null normalization, which will make the class more robust by ensuring the tenant field is never null, regardless of how the MessageSendParams object is instantiated.

The `tenant` field in `MessageSendParams` was previously required and
validated as non-null in the compact constructor, which forced callers
to always provide a tenant even when it is not applicable.

This change makes `tenant` truly optional:
- Remove `Assert.checkNotNullParam("tenant", tenant)` from the compact
  constructor so that null values are accepted at construction time
- Annotate the `tenant` record component with `@Nullable` to clearly
  signal that null may be passed by callers
- Normalize null tenant to an empty string in the compact constructor,
  which is the single point of normalization for all construction paths
- Update `Builder.tenant()` to accept a `@Nullable String` so that
  callers can explicitly pass null without a type violation
- Simplify `Builder.build()` to pass `tenant` directly, delegating
  normalization to the compact constructor

Javadoc is updated across the class to accurately reflect the optional
nature, default value, and normalization behavior of `tenant`.

Fixes: a2aproject#693
@CokeLee777
Copy link
Contributor Author

/gemini review

Copy link
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 aims to make the tenant field in MessageSendParams optional, which is a good improvement. However, the current implementation of normalizing the tenant in a compact constructor will cause a compilation error because compact constructor parameters are final and cannot be reassigned. I've provided a critical comment with a suggested fix that uses a canonical constructor to perform the normalization, which is the correct approach for this scenario. This ensures the code is correct and maintains the desired invariant.

@ehsavoie
Copy link
Collaborator

ehsavoie commented Mar 2, 2026

I think this is wrong: the tenant is a path parameter where "" does make sense. Having something that can be null requires testing at each usage. Also the same pattern is repeated across all the source code. So I disagree with this PR

Copy link
Collaborator

@ehsavoie ehsavoie left a comment

Choose a reason for hiding this comment

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

This is not a bug IMO

@CokeLee777
Copy link
Contributor Author

@ehsavoie
Thank you for review.
I commented about this PR in #693

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]: MessageSendParams#tenant is documented as optional but enforces a non-null check in the constructor

2 participants