Skip to content

Detect triggers: keyword misuse in compile with actionable error#19142

Merged
pelikhan merged 2 commits intomainfrom
copilot/fix-trigger-keyword-error
Mar 2, 2026
Merged

Detect triggers: keyword misuse in compile with actionable error#19142
pelikhan merged 2 commits intomainfrom
copilot/fix-trigger-keyword-error

Conversation

Copy link
Contributor

Copilot AI commented Mar 2, 2026

Authoring agents occasionally emit triggers: instead of on: for event definitions. Previously this silently caused the workflow to be treated as a shared/imported workflow (no on: → shared workflow path), masking the real problem.

Changes

  • pkg/workflow/compiler_orchestrator_frontmatter.go — Added early detection of triggers: key before the shared-workflow fallback path. Returns a clear error pointing to the correct key:

    <file>: invalid frontmatter key 'triggers:' — use 'on:' to define workflow triggers
    
  • pkg/workflow/compiler_orchestrator_frontmatter_test.go — Added TestParseFrontmatterSection_TriggersInsteadOfOn covering this error path.

  • .github/aw/create-agentic-workflow.md — Updated the Triggers step to explicitly call out that triggers: is invalid and on: is required, preventing the agent from generating broken workflows in the first place.

Original prompt

The authoring agent sometimes decide to generate "triggers:" instead of "on:" as the keyword for event definition.

  • detect this error mode in compile and provide a meaningful error message to correct it
  • review and update the create-agentic-workflows.md prompt to ensure the agent uses "on" keyword.

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.



✨ PR Review Safe Output Test - Run 22557033498

💥 [THE END] — Illustrated by Smoke Claude

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Detect incorrect use of triggers keyword in event definitions Detect triggers: keyword misuse in compile with actionable error Mar 2, 2026
@pelikhan pelikhan marked this pull request as ready for review March 2, 2026 00:55
Copilot AI review requested due to automatic review settings March 2, 2026 00:55
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

Adds an explicit compile-time check to catch workflows that mistakenly use triggers: instead of on: for GitHub Actions event definitions, returning a clear, actionable error rather than silently falling back to “shared workflow” detection.

Changes:

  • Add early detection of triggers frontmatter key and return a targeted error instructing to use on.
  • Add a unit test covering the triggers: misuse case.
  • Update the workflow-authoring guidance to explicitly forbid triggers: and require on:.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
pkg/workflow/compiler_orchestrator_frontmatter.go Adds early validation to fail fast on triggers: misuse before shared-workflow fallback.
pkg/workflow/compiler_orchestrator_frontmatter_test.go Adds coverage ensuring triggers: produces an actionable error.
.github/aw/create-agentic-workflow.md Updates authoring instructions to prevent agents from generating invalid triggers: frontmatter.

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

Comment on lines +74 to +77
// Check if user accidentally used "triggers:" instead of the correct "on:" keyword
if _, hasTriggers := frontmatterForValidation["triggers"]; hasTriggers {
return nil, fmt.Errorf("%s: invalid frontmatter key 'triggers:' — use 'on:' to define workflow triggers", cleanPath)
}
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

The new triggers frontmatter check is only implemented in parseFrontmatterSection (file-based compilation). The string-based entry point (Compiler.ParseWorkflowString in pkg/workflow/compiler_string_api.go) still treats missing on as a shared workflow and will return SharedWorkflowError, so users of the Wasm/programmatic API will not get the actionable triggers: guidance. Consider adding the same triggers detection (and error message) to ParseWorkflowString for consistent behavior across compilation paths.

Copilot uses AI. Check for mistakes.
@pelikhan pelikhan merged commit c2ce8fd into main Mar 2, 2026
110 checks passed
@pelikhan pelikhan deleted the copilot/fix-trigger-keyword-error branch March 2, 2026 03:54
github-actions bot added a commit that referenced this pull request Mar 2, 2026
- Add error entry for invalid 'triggers:' frontmatter key (#19142)
  Authoring agents sometimes use 'triggers:' instead of 'on:'; the
  compiler now detects this with a clear actionable error message.

- Document that GitHub MCP server always operates in read-only mode (#19092)
  The dangerous-permissions-write feature flag was removed; read-only
  is now always enforced. Add compilation error for read-only: false.
  Update getting-started-mcp.md, github-tools.md, frontmatter-full.md.

Co-Authored-By: Claude Sonnet 4.6 <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.

3 participants