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 []string
But 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"] = namesAny
The 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
activation job's if: condition — it will not contain a github.event.label.name check
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
Bug Description
When using the label trigger shorthand syntax (e.g.
on: pull_request labeled my-label), the compiled.lock.ymldoes not include a label name condition in the activation job'sif:clause. This means the workflow triggers on anylabeledevent, 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 thenamesfield as[]string:But in
pkg/workflow/filters.go,applyLabelFilter()only type-asserts forstringor[]any:In Go,
[]stringis 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
[]stringto[]anyinexpandLabelTriggerShorthandbefore storing:The tests in
label_trigger_parser_test.go(line 382) andlabel_trigger_parser_fuzz_test.go(line 144) also assert[]stringand need to be updated to[]any.Reproduction
on: pull_request labeled architecture-review-neededgh aw compileactivationjob'sif:condition — it will not contain agithub.event.label.namecheckExpected Behavior
The compiled
activationjob should include:Versions Tested