Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/aw/create-agentic-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions pkg/workflow/compiler_orchestrator_frontmatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Comment on lines +74 to +77
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.

// Check if "on" field is missing - if so, treat as a shared/imported workflow
_, hasOnField := frontmatterForValidation["on"]
if !hasOnField {
Expand Down
30 changes: 30 additions & 0 deletions pkg/workflow/compiler_orchestrator_frontmatter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading