Skip to content

Validate required workflows on workflow_run during compile#33191

Merged
pelikhan merged 7 commits into
mainfrom
copilot/bug-gh-aw-compile-validate-workflows-field
May 19, 2026
Merged

Validate required workflows on workflow_run during compile#33191
pelikhan merged 7 commits into
mainfrom
copilot/bug-gh-aw-compile-validate-workflows-field

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 19, 2026

gh aw compile currently allows on.workflow_run without workflows, producing .lock.yml files that GitHub rejects at runtime (on.workflow_run does not reference any workflows). This change moves that failure to compile-time by enforcing workflow_run.workflows as required and non-empty.

  • Compiler validation

    • Extended workflow_run trigger validation to fail compilation when workflows is missing, empty, or whitespace-only.
    • Kept existing branch-restriction behavior intact; workflows validation is now enforced first for invalid trigger definitions.
  • Error quality

    • Added a targeted compile error message with an inline YAML fix example so users can correct frontmatter immediately.
  • Test coverage

    • Added focused cases for:
      • missing workflows
      • workflows: []
      • workflows containing only whitespace entries
on:
  workflow_run:
    types: [completed]   # before: compiled, then failed on GitHub

Now this is rejected at compile time unless workflows includes at least one non-empty workflow name.

Copilot AI and others added 6 commits May 19, 2026 03:00
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix workflow validation for workflow_run trigger in gh aw compile Validate required workflows on workflow_run during compile May 19, 2026
Copilot AI requested a review from pelikhan May 19, 2026 03:07
@pelikhan pelikhan marked this pull request as ready for review May 19, 2026 03:36
Copilot AI review requested due to automatic review settings May 19, 2026 03:36
Copy link
Copy Markdown
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

Moves validation of on.workflow_run.workflows from runtime (GitHub Actions reject) to compile time in gh aw compile, so users get immediate, actionable feedback when the field is missing, empty, or contains only whitespace entries.

Changes:

  • Added a workflows presence/non-empty check to validateWorkflowRunBranches with a multi-line error message that includes a YAML fix example.
  • Introduced helper hasNonEmptyWorkflowRunWorkflows supporting string, []string, and []any shapes.
  • Added three test cases covering missing, empty list, and whitespace-only workflows.
Show a summary per file
File Description
pkg/workflow/agent_validation.go Adds required workflows validation and helper; updates function-doc comment and log message.
pkg/workflow/workflow_run_validation_test.go Adds three test cases for missing/empty/whitespace workflows.
pkg/workflow/expression_extraction_test.go Minor gofmt-style reformat of a test case struct literal.

Copilot's findings

Tip

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

  • Files reviewed: 2/3 changed files
  • Comments generated: 0

@pelikhan pelikhan merged commit 974e326 into main May 19, 2026
4 checks passed
@pelikhan pelikhan deleted the copilot/bug-gh-aw-compile-validate-workflows-field branch May 19, 2026 04:04
github-actions Bot added a commit that referenced this pull request May 19, 2026
…s: current, ignore-if-missing, and workflow_run.workflows validation

Documents user-facing changes from PRs merged in the last 24 hours:

- gh aw add / add-wizard now accept arbitrary HTTP(S) URLs and JSON
  workflow definitions (from #33164)
- network.allowed-input opt-in input for caller-extensible reusable
  workflow allowlists (from #33200)
- tools.github.allowed-repos: current macro for repo-scoped MCP guard
  policies (from #33041)
- safe-outputs.github-app.ignore-if-missing flag for graceful App-token
  skip on fork/missing-secret runs (from #33033)
- workflow_run.workflows now required at compile time (from #33191)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

bug: gh aw compile should validate required workflows: field on workflow_run trigger

3 participants