Detect triggers: keyword misuse in compile with actionable error#19142
Detect triggers: keyword misuse in compile with actionable error#19142
triggers: keyword misuse in compile with actionable error#19142Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
triggers: keyword misuse in compile with actionable error
There was a problem hiding this comment.
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
triggersfrontmatter key and return a targeted error instructing to useon. - Add a unit test covering the
triggers:misuse case. - Update the workflow-authoring guidance to explicitly forbid
triggers:and requireon:.
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.
| // 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) | ||
| } |
There was a problem hiding this comment.
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.
- 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>
Authoring agents occasionally emit
triggers:instead ofon:for event definitions. Previously this silently caused the workflow to be treated as a shared/imported workflow (noon:→ shared workflow path), masking the real problem.Changes
pkg/workflow/compiler_orchestrator_frontmatter.go— Added early detection oftriggers:key before the shared-workflow fallback path. Returns a clear error pointing to the correct key:pkg/workflow/compiler_orchestrator_frontmatter_test.go— AddedTestParseFrontmatterSection_TriggersInsteadOfOncovering this error path..github/aw/create-agentic-workflow.md— Updated the Triggers step to explicitly call out thattriggers:is invalid andon:is required, preventing the agent from generating broken workflows in the first place.Original prompt
💡 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