From dbddf98a21b503bb24767500c3d5ade6592a041d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Mar 2026 00:39:43 +0000 Subject: [PATCH 1/2] Initial plan From 49a3b55e924310745350f9ccf45f97e0d59338b7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Mar 2026 00:48:49 +0000 Subject: [PATCH 2/2] Detect triggers: keyword error in compile and update authoring prompt Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .github/aw/create-agentic-workflow.md | 2 +- .../compiler_orchestrator_frontmatter.go | 5 ++++ .../compiler_orchestrator_frontmatter_test.go | 30 +++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/.github/aw/create-agentic-workflow.md b/.github/aw/create-agentic-workflow.md index c3c4ea0f07d..099d5d1d57b 100644 --- a/.github/aw/create-agentic-workflow.md +++ b/.github/aw/create-agentic-workflow.md @@ -573,7 +573,7 @@ Should run when issues are opened or edited Based on the parsed requirements, determine: 1. **Workflow ID**: Convert the workflow name to kebab-case (e.g., "Issue Classifier" → "issue-classifier") -2. **Triggers**: Infer appropriate triggers from the description: +2. **Triggers**: Infer appropriate triggers from the description. **Always use `on:` as the YAML key** — never use `triggers:` (that is not a valid frontmatter key and will cause a compile error): - Issue automation → `on: issues: types: [opened, edited]` (add `workflow_dispatch:` manually if manual runs needed) - PR automation → `on: pull_request: types: [opened, synchronize]` (add `workflow_dispatch:` manually if manual runs needed) - Scheduled tasks → `on: schedule: daily on weekdays` (prefer weekdays to avoid Monday backlog - workflow_dispatch auto-added for fuzzy schedules only) diff --git a/pkg/workflow/compiler_orchestrator_frontmatter.go b/pkg/workflow/compiler_orchestrator_frontmatter.go index db4929561f8..9e533a957da 100644 --- a/pkg/workflow/compiler_orchestrator_frontmatter.go +++ b/pkg/workflow/compiler_orchestrator_frontmatter.go @@ -71,6 +71,11 @@ func (c *Compiler) parseFrontmatterSection(markdownPath string) (*frontmatterPar // Keep the original frontmatter with markers for YAML generation frontmatterForValidation := c.copyFrontmatterWithoutInternalMarkers(result.Frontmatter) + // 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) + } + // Check if "on" field is missing - if so, treat as a shared/imported workflow _, hasOnField := frontmatterForValidation["on"] if !hasOnField { diff --git a/pkg/workflow/compiler_orchestrator_frontmatter_test.go b/pkg/workflow/compiler_orchestrator_frontmatter_test.go index 960f9e6a162..6f91702622d 100644 --- a/pkg/workflow/compiler_orchestrator_frontmatter_test.go +++ b/pkg/workflow/compiler_orchestrator_frontmatter_test.go @@ -71,6 +71,36 @@ Can be imported assert.True(t, result.isSharedWorkflow, "Should be detected as shared workflow") } +// TestParseFrontmatterSection_TriggersInsteadOfOn tests that using "triggers:" gives a helpful error +func TestParseFrontmatterSection_TriggersInsteadOfOn(t *testing.T) { + tmpDir := testutil.TempDir(t, "frontmatter-triggers") + + testContent := `--- +triggers: + issues: + types: [opened] +engine: copilot +permissions: + contents: read +--- + +# Test Workflow + +Content here +` + + testFile := filepath.Join(tmpDir, "test.md") + require.NoError(t, os.WriteFile(testFile, []byte(testContent), 0644)) + + compiler := NewCompiler() + result, err := compiler.parseFrontmatterSection(testFile) + + require.Error(t, err, "Using 'triggers:' instead of 'on:' should cause error") + assert.Nil(t, result) + assert.Contains(t, err.Error(), "'triggers:'", "Error should mention the invalid key") + assert.Contains(t, err.Error(), "'on:'", "Error should mention the correct key") +} + // TestParseFrontmatterSection_MissingFrontmatter tests error for no frontmatter func TestParseFrontmatterSection_MissingFrontmatter(t *testing.T) { tmpDir := testutil.TempDir(t, "frontmatter-missing")