Skip to content

Add validation rules for task execution fields#112

Open
Copilot wants to merge 7 commits intomainfrom
copilot/add-validation-rule
Open

Add validation rules for task execution fields#112
Copilot wants to merge 7 commits intomainfrom
copilot/add-validation-rule

Conversation

Copy link
Contributor

Copilot AI commented Feb 22, 2026

A Task could silently accept multiple conflicting execution fields with no indication of which would take precedence. This adds validation rules that enforce supported combinations.

Rules

  • command and sh are mutually exclusive (both specify how to invoke the process)
  • manifests cannot be combined with image, command, or sh (Kubernetes manifest tasks are a distinct execution model)
  • image may be combined with command or sh (the command overrides the container entrypoint)

Changes

  • internal/types/task.go — Added Task.Validate() method enforcing the above rules
  • internal/run.go — Calls Validate() on all tasks at the start of RunSubgraph before any execution begins
  • internal/types/task_test.go — Tests covering valid and invalid field combinations
  • internal/run_test.go — Test asserting that an invalid task produces the expected wrapped error from RunSubgraph

Example

A task like this now fails fast with a clear error:

tasks:
  bad-task:
    sh: echo hello
    command: [echo, hello]
task "bad-task" is invalid: only one of command or sh is allowed

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…er task

Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Copilot AI changed the title [WIP] Add validation rule for single command type Add mutual exclusivity validation for task execution fields Feb 22, 2026
Copilot AI requested a review from alexec February 22, 2026 19:37
@alexec alexec marked this pull request as ready for review February 24, 2026 23:53
Copilot AI review requested due to automatic review settings February 24, 2026 23:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a Task.Validate() method intended to prevent ambiguous task execution by enforcing mutual exclusivity across task execution-related fields, and wires that validation into RunSubgraph so invalid workflows fail before execution begins.

Changes:

  • Added (*types.Task).Validate() to detect conflicting execution fields and return a descriptive error.
  • Added early validation in internal.RunSubgraph to fail fast on invalid tasks.
  • Added unit tests for Task.Validate() conflict scenarios.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
internal/types/task.go Adds Task.Validate() for execution-field conflict detection.
internal/run.go Calls Validate() on all tasks before any execution begins.
internal/types/task_test.go Adds tests validating the new mutual-exclusivity behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +34 to +39
// validate all tasks
for name, task := range wf.Tasks {
if err := task.Validate(); err != nil {
return fmt.Errorf("task %q is invalid: %w", name, err)
}
}
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RunSubgraph now fails fast by validating tasks before execution, but there’s no test coverage asserting that an invalid task produces the expected wrapped error (e.g. task %q is invalid: ...). Adding a small case in internal/run_test.go would prevent regressions and ensure the new validation is actually exercised in the runner path.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a "Invalid task" test case to internal/run_test.go that verifies an invalid workflow (task with both command and sh) returns the expected wrapped error task "job" is invalid: only one of command or sh is allowed. Also fixed the task_test.go error message expectations to align with the updated Validate() implementation. Commit: 674557a

alexec and others added 3 commits February 27, 2026 07:30
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Alex Collins <alexec@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Alex Collins <alexec@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Alex Collins <alexec@users.noreply.github.com>
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Copilot AI changed the title Add mutual exclusivity validation for task execution fields Add validation rules for task execution fields Feb 27, 2026
Copilot AI requested a review from alexec February 27, 2026 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants