Skip to content

Commit eb59d5f

Browse files
committed
fix: Make tenant truly optional in MessageSendParams
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 removes that null assertion and ensures null tenant values are normalized to an empty string at every entry point: the convenience constructor explicitly passes `""`, and `Builder.build()` normalizes null to `""`. `Builder.tenant()` is updated to accept `@Nullable String` to reflect that tenant is optional. The `tenant` record component is declared as non-null (`String`) since its getter never returns null after normalization. Javadoc is updated across the class to accurately describe the optional nature, default value, and behavior of `tenant`. Fixes: #693
1 parent c595071 commit eb59d5f

1 file changed

Lines changed: 8 additions & 13 deletions

File tree

‎spec/src/main/java/io/a2a/spec/MessageSendParams.java‎

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* @param message the message to send to the agent (required)
1818
* @param configuration optional configuration for message processing behavior
1919
* @param metadata optional arbitrary key-value metadata for the request
20-
* @param tenant optional tenant, provided as a path parameter.
20+
* @param tenant optional tenant identifier provided as a path parameter; defaults to empty string if not specified
2121
* @see MessageSendConfiguration for available configuration options
2222
* @see <a href="https://a2a-protocol.org/latest/">A2A Protocol Specification</a>
2323
*/
@@ -26,20 +26,14 @@ public record MessageSendParams(Message message, @Nullable MessageSendConfigurat
2626

2727
/**
2828
* Compact constructor for validation.
29-
* Validates that required parameters are not null.
30-
*
31-
* @param message the message to send
32-
* @param configuration optional message send configuration
33-
* @param metadata optional metadata
34-
* @param tenant the tenant identifier
29+
* Validates that {@code message} is not null.
3530
*/
3631
public MessageSendParams {
3732
Assert.checkNotNullParam("message", message);
38-
Assert.checkNotNullParam("tenant", tenant);
3933
}
4034

4135
/**
42-
* Convenience constructor with default tenant.
36+
* Convenience constructor that sets tenant to empty string by default.
4337
*
4438
* @param message the message to send (required)
4539
* @param configuration optional configuration for message processing
@@ -50,9 +44,9 @@ public MessageSendParams(Message message, @Nullable MessageSendConfiguration con
5044
}
5145

5246
/**
53-
* Create a new Builder
47+
* Creates a new {@link Builder} for constructing {@link MessageSendParams}.
5448
*
55-
* @return the builder
49+
* @return a new builder instance
5650
*/
5751
public static Builder builder() {
5852
return new Builder();
@@ -112,16 +106,17 @@ public Builder metadata(@Nullable Map<String, Object> metadata) {
112106
/**
113107
* Sets optional tenant for the request.
114108
*
115-
* @param tenant arbitrary key-value metadata
109+
* @param tenant optional tenant identifier
116110
* @return this builder
117111
*/
118-
public Builder tenant(String tenant) {
112+
public Builder tenant(@Nullable String tenant) {
119113
this.tenant = tenant;
120114
return this;
121115
}
122116

123117
/**
124118
* Builds the {@link MessageSendParams}.
119+
* If tenant was not set or set to null, it defaults to an empty string.
125120
*
126121
* @return a new message send parameters instance
127122
* @throws IllegalArgumentException if message is null

0 commit comments

Comments
 (0)