Skip to content

Commit 70d2973

Browse files
authored
Merge pull request #104 from fjuma/spec
Add validation for parts and historyLength
2 parents b8999c7 + 48be950 commit 70d2973

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

src/main/java/io/a2a/spec/Artifact.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ public record Artifact(String artifactId, String name, String description, List<
1818
public Artifact {
1919
Assert.checkNotNullParam("artifactId", artifactId);
2020
Assert.checkNotNullParam("parts", parts);
21+
if (parts.isEmpty()) {
22+
throw new IllegalArgumentException("Parts cannot be empty");
23+
}
2124
}
2225

2326
public static class Builder {

src/main/java/io/a2a/spec/Message.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ public Message(@JsonProperty("role") Role role, @JsonProperty("parts") List<Part
4444
@JsonProperty("kind") String kind) {
4545
Assert.checkNotNullParam("kind", kind);
4646
Assert.checkNotNullParam("parts", parts);
47+
if (parts.isEmpty()) {
48+
throw new IllegalArgumentException("Parts cannot be empty");
49+
}
4750
Assert.checkNotNullParam("role", role);
4851
if (! kind.equals(MESSAGE)) {
4952
throw new IllegalArgumentException("Invalid Message");

src/main/java/io/a2a/spec/MessageSendConfiguration.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ public record MessageSendConfiguration(List<String> acceptedOutputModes, Integer
2020

2121
public MessageSendConfiguration {
2222
Assert.checkNotNullParam("acceptedOutputModes", acceptedOutputModes);
23+
if (historyLength != null && historyLength < 0) {
24+
throw new IllegalArgumentException("Invalid history length");
25+
}
2326
}
2427

2528
public static class Builder {

src/main/java/io/a2a/spec/TaskQueryParams.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ public record TaskQueryParams(String id, Integer historyLength, Map<String, Obje
1919

2020
public TaskQueryParams {
2121
Assert.checkNotNullParam("id", id);
22+
if (historyLength != null && historyLength < 0) {
23+
throw new IllegalArgumentException("Invalid history length");
24+
}
2225
}
2326

2427
public TaskQueryParams(String id) {

0 commit comments

Comments
 (0)