-
Notifications
You must be signed in to change notification settings - Fork 277
Description
Bug Description
When using the label trigger shorthand syntax (e.g. on: pull_request labeled my-label), the compiled .lock.yml does not include a label name condition in the activation job's if: clause. This means the workflow triggers on any labeled event, not just the specified label(s).
The YAML-format syntax (on: pull_request: types: [labeled] names: [my-label]) works correctly.
Root Cause
In pkg/workflow/label_trigger_parser.go, expandLabelTriggerShorthand() stores the names field as []string:
triggerConfig["names"] = labelNames // labelNames is []stringBut in pkg/workflow/filters.go, applyLabelFilter() only type-asserts for string or []any:
if namesStr, isNamesStr := namesValue.(string); isNamesStr {
labelNames = []string{namesStr}
} else if namesArray, isNamesArray := namesValue.([]any); isNamesArray {
// ...
}In Go, []string is not assignable to []any, so both branches fail silently. The label filter is never applied.
When the YAML format is used, YAML unmarshalling naturally produces []any{"my-label"}, which is why that path works correctly.
Fix
Convert []string to []any in expandLabelTriggerShorthand before storing:
namesAny := make([]any, len(labelNames))
for i, name := range labelNames {
namesAny[i] = name
}
triggerConfig["names"] = namesAnyThe tests in label_trigger_parser_test.go (line 382) and label_trigger_parser_fuzz_test.go (line 144) also assert []string and need to be updated to []any.
Reproduction
- Create a workflow with shorthand:
on: pull_request labeled architecture-review-needed - Compile with
gh aw compile - Inspect the
activationjob'sif:condition — it will not contain agithub.event.label.namecheck
Expected Behavior
The compiled activation job should include:
github.event.label.name == 'architecture-review-needed'
Versions Tested
- gh-aw v0.51.0 and v0.53.4 — both affected