Skip to content

[plan] Add minItems constraints for array fields requiring values #7579

@github-actions

Description

@github-actions

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

  1. on.issues.types when using label triggers

    • Must have at least one label
    • Code: pkg/workflow/bundler_validation.go
  2. tools.(tool).toolsets when specified

    • Empty toolsets array is meaningless
    • Should either be omitted or have values
  3. network.allowed when specified

    • Empty allowed list contradicts intent
    • Should use network.enabled: false instead
  4. 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

  • Schema rejects empty arrays for fields requiring values
  • Error messages explain minimum item requirements
  • Optional arrays that can be empty are documented in $comment
  • Existing valid configurations still pass validation

Testing

Create test workflows with empty arrays and verify schema validation catches them.
Related to #7575

AI generated by Plan Command for discussion #7569

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions