You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: MessageSendParams#tenant is documented as optional but enforces a non-null check in the constructor #693
This is inconsistent with the inner Builder class, which declares @Nullable String tenant and handles null gracefully by substituting an empty string in build().
Expected behavior
Since tenant is documented as optional, passing null should be permitted. The record declaration should include @Nullable on tenant, and the null check in the compact constructor should be removed.
Relevant log output
``
java.lang.IllegalArgumentException: WFLYUTIL0097: Method parameter 'tenant' cannot be null
at io.a2a.util.Assert.checkNotNullParam(Assert.java:...)
at io.a2a.spec.MessageSendParams.<init>(MessageSendParams.java:38)## Relevant files
- `spec/src/main/java/io/a2a/spec/MessageSendParams.java` — lines 20, 25, 38
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 being a bug.
@ehsavoie
Thanks for the review. I understand that the constructor-level null check is intentional for programmatic construction paths.
The issue I'm facing is specifically during Gson deserialization. When using JsonUtil.fromJson(body, SendMessageRequest.class), Gson recursively deserializes the inner MessageSendParams field as well. If the incoming JSON payload doesn't contain a tenant field in params, Gson sets it to null via reflection — bypassing the Builder and the 3-arg constructor that default it to "". This means SendMessageRequest itself becomes unparseable through JsonUtil whenever tenant is absent from the JSON, which is the standard case when the client sends a message via A2A.toUserMessage() + client.sendMessage(), since neither of those APIs sets a tenant value.
Would you be open to an alternative approach, such as registering a custom Gson TypeAdapter for MessageSendParams in JsonUtil that normalizes a null tenant to "" before passing it to the constructor? This way, the constructor's null check remains intact for all programmatic paths while keeping SendMessageRequest deserializable via the SDK's own JsonUtil.
Alternatively, is there a recommended way to set the tenant on the client side before sending a message?
I agree that something is missing there even if you use sendMessage(@NonNull MessageSendParams params, @NonNull List<BiConsumer<ClientEvent, AgentCard>> consumers, @Nullable Consumer<Throwable> streamingErrorHandler, @Nullable ClientCallContext context) throws A2AClientException;
you can set the tenant on the params here.
I'm wondering if we could use the ClientCallContext to pass on the tenant or if we should provide another set of methods
Thank you for the review and the discussion! I'll close #694 for now and take more time to think about a better approach that addresses the design more fundamentally. If anyone has ideas on the best way to handle this, please feel free to share in the issue!
Activity
CokeLee777 commentedon Mar 1, 2026
I'll work on a fix for this and open a PR.
fix: Make tenant optional in MessageSendParams
fix: Make tenant optional in MessageSendParams
fix: Make tenant truly optional in MessageSendParams
fix: Make tenant truly optional in MessageSendParams
fix: Make tenant optional in MessageSendParams
ehsavoie commentedon Mar 2, 2026
It should be an empty string, the builder enforces that.
ehsavoie commentedon 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 being a bug.
CokeLee777 commentedon Mar 2, 2026
@ehsavoie
Thanks for the review. I understand that the constructor-level null check is intentional for programmatic construction paths.
The issue I'm facing is specifically during Gson deserialization. When using
JsonUtil.fromJson(body, SendMessageRequest.class), Gson recursively deserializes the innerMessageSendParamsfield as well. If the incoming JSON payload doesn't contain atenantfield inparams, Gson sets it tonullvia reflection — bypassing the Builder and the 3-arg constructor that default it to"". This meansSendMessageRequestitself becomes unparseable throughJsonUtilwhenevertenantis absent from the JSON, which is the standard case when the client sends a message viaA2A.toUserMessage()+client.sendMessage(), since neither of those APIs sets atenantvalue.Would you be open to an alternative approach, such as registering a custom Gson TypeAdapter for
MessageSendParamsinJsonUtilthat normalizes a nulltenantto""before passing it to the constructor? This way, the constructor's null check remains intact for all programmatic paths while keepingSendMessageRequestdeserializable via the SDK's ownJsonUtil.Alternatively, is there a recommended way to set the tenant on the client side before sending a message?
ehsavoie commentedon Mar 3, 2026
I agree that something is missing there even if you use
sendMessage(@NonNull MessageSendParams params, @NonNull List<BiConsumer<ClientEvent, AgentCard>> consumers, @Nullable Consumer<Throwable> streamingErrorHandler, @Nullable ClientCallContext context) throws A2AClientException;you can set the tenant on the params here.
I'm wondering if we could use the ClientCallContext to pass on the tenant or if we should provide another set of methods
CokeLee777 commentedon Mar 3, 2026
Thank you for the review and the discussion! I'll close #694 for now and take more time to think about a better approach that addresses the design more fundamentally. If anyone has ideas on the best way to handle this, please feel free to share in the issue!