Skip to content

Commit e0f782d

Browse files
committed
fix: Make tenant optional in MessageSendParams
The `tenant` field in `MessageSendParams` was previously required and validated as non-null, which forced callers to always provide a tenant even when it is not applicable. This change makes `tenant` optional by annotating it with `@Nullable` and removing the null-check in the compact constructor. The `Builder.tenant()` method is also updated to accept a nullable value. Javadoc is updated to reflect the new optional semantics. Fixes: #693
1 parent c595071 commit e0f782d

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,21 @@
2222
* @see <a href="https://a2a-protocol.org/latest/">A2A Protocol Specification</a>
2323
*/
2424
public record MessageSendParams(Message message, @Nullable MessageSendConfiguration configuration,
25-
@Nullable Map<String, Object> metadata, String tenant) {
25+
@Nullable Map<String, Object> metadata, @Nullable String tenant) {
2626

2727
/**
28-
* Compact constructor for validation.
29-
* Validates that required parameters are not null.
28+
* Compact constructor for validation and normalization.
29+
* Validates that required parameters are not null and normalizes.
30+
* optional parameters to their default values.
3031
*
3132
* @param message the message to send
3233
* @param configuration optional message send configuration
3334
* @param metadata optional metadata
34-
* @param tenant the tenant identifier
35+
* @param tenant optional tenant identifier; defaults to empty string if null
3536
*/
3637
public MessageSendParams {
3738
Assert.checkNotNullParam("message", message);
38-
Assert.checkNotNullParam("tenant", tenant);
39+
tenant = tenant == null ? "" : tenant;
3940
}
4041

4142
/**
@@ -46,7 +47,7 @@ public record MessageSendParams(Message message, @Nullable MessageSendConfigurat
4647
* @param metadata optional metadata
4748
*/
4849
public MessageSendParams(Message message, @Nullable MessageSendConfiguration configuration, @Nullable Map<String, Object> metadata) {
49-
this(message, configuration, metadata, "");
50+
this(message, configuration, metadata, null);
5051
}
5152

5253
/**
@@ -112,10 +113,10 @@ public Builder metadata(@Nullable Map<String, Object> metadata) {
112113
/**
113114
* Sets optional tenant for the request.
114115
*
115-
* @param tenant arbitrary key-value metadata
116+
* @param tenant tenant identifier
116117
* @return this builder
117118
*/
118-
public Builder tenant(String tenant) {
119+
public Builder tenant(@Nullable String tenant) {
119120
this.tenant = tenant;
120121
return this;
121122
}
@@ -131,7 +132,7 @@ public MessageSendParams build() {
131132
Assert.checkNotNullParam("message", message),
132133
configuration,
133134
metadata,
134-
tenant == null ? "" : tenant);
135+
tenant);
135136
}
136137
}
137138
}

0 commit comments

Comments
 (0)