Objective
Add minItems: 1 constraints to array fields that require at least one value.
Context
Several array fields must have at least one item to be meaningful (e.g., on.issues.types with label triggers), but the schema doesn't enforce this. Users can specify empty arrays that fail at compile time.
Fields Requiring minItems
-
on.issues.types when using label triggers
- Must have at least one label
- Code:
pkg/workflow/bundler_validation.go
-
tools.(tool).toolsets when specified
- Empty toolsets array is meaningless
- Should either be omitted or have values
-
network.allowed when specified
- Empty allowed list contradicts intent
- Should use
network.enabled: false instead
-
permissions scopes arrays when specified
- Empty permission arrays are meaningless
Approach
Add minItems to array definitions:
{
"types": {
"type": "array",
"items": { "type": "string" },
"minItems": 1,
"$comment": "At least one issue type required for label triggers"
}
}
For optional arrays that can be empty, document why in $comment.
Files to Modify
pkg/parser/schemas/frontmatter.json - Add minItems constraints
- After changes, run
make build to rebuild with embedded schema
Acceptance Criteria
Testing
Create test workflows with empty arrays and verify schema validation catches them.
Related to #7575
AI generated by Plan Command for discussion #7569