[Feat]: Add `min_items = 1` constraint to `Artifact` in protobuf schema
- 主要語言
- Shell
- 星號
- 25.7k
- 分支
- 2.6k
- 平均合併
- 3 天 6 小時
- 30 天內合併 PR
- 16
描述
### Is your feature request related to a problem? Please describe.
The [A2A Protocol Specification (Section 4.1.7)](https://a2a-protocol.org/latest/specification/#artifact) states that an Artifact's `parts` array "Must contain at least one part."
However, this constraint is not reflected in the protobuf schema definition at `specification/a2a.proto`.
### Describe the solution you'd like
### Current Schema
**specification/a2a.proto**
```proto
message Artifact {
// Unique identifier (e.g. UUID) for the artifact. It must be at least unique
// within a task.
string artifact_id = 1 [(google.api.field_behavior) = REQUIRED];
// A human readable name for the artifact.
string name = 3;
// A human readable description of the artifact, optional.
string description = 4;
// The content of the artifact. Must contain at least one part.
repeated Part parts = 5 [(google.api.field_behavior) = REQUIRED];
// Optional metadata included with the artifact.
google.protobuf.Struct metadata = 6;
// The URIs of extensions that are present or contributed to this Artifact.
repeated string extensions = 7;
}
```
**specification/buf.yaml**
```yaml
version: v2
deps:
# Common Protobuf types.
- buf.build/googleapis/googleapis
```
### Proposed Change
**specification/a2a.proto**
```diff
+ import "buf/validate/validate.proto";
message Artifact {
// Unique identifier (e.g. UUID) for the artifact. It must be at least unique
// within a task.
string artifact_id = 1 [(google.api.field_behavior) = REQUIRED];
// A human readable name for the artifact.
string name = 3;
// A human readable description of the artifact, optional.
string description = 4;
// The content of the artifact. Must contain at least one part.
- repeated Part parts = 5 [(google.api.field_behavior) = REQUIRED];
+ repeated Part parts = 5 [
+ (google.api.field_behavior) = REQUIRED,
+ (buf.validate.field).repeated.min_items = 1
+ ];
// Optional metadata included with the artifact.
google.protobuf.Struct metadata = 6;
// The URIs of extensions that are present or contributed to this Artifact.
repeated string extensions = 7;
}
```
**specification/buf.yaml**
```diff
version: v2
deps:
# Common Protobuf types.
- buf.build/googleapis/googleapis
+ - buf.build/bufbuild/protovalidate
```
## Why This Matters
SDKs that generate models from predefined schema in A2A repository (e.g., https://github.com/a2aproject/a2a-python using `datamodel-codegen`) do not automatically enforce the non-empty constraint because the schema lacks `min_items`. This means invalid `Artifact` objects with empty parts can be created without any validation error.
- The Java SDK already enforces this at the code level but this should be driven by the schema itself.
- https://github.com/a2aproject/a2a-java/blob/v0.3.3.Final/spec/src/main/java/io/a2a/spec/Artifact.java
- The Python SDK applied a manual fix in below but since `types.py` is auto-generated from this schema, the fix will be overwritten on the next regeneration.
- https://github.com/a2aproject/a2a-python/issues/670
- https://github.com/a2aproject/a2a-python/pull/671
### Describe alternatives you've considered
_No response_
### Additional context
_No response_
### Code of Conduct
- [x] I agree to follow this project's Code of Conduct
貢獻指南
評估
這個 Issue 還沒有評估資料。