From 0d3396f005069e8b12dd439c754677e5fcdfb3a3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 11 May 2026 04:29:59 +0000 Subject: [PATCH 01/12] Initial plan From 8114e61e6fce912b82c4c4fdb7a055d28098d0f2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 11 May 2026 04:38:44 +0000 Subject: [PATCH 02/12] Comment out on.labels in generated on section Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/workflow/frontmatter_extraction_yaml.go | 27 ++++++++++++++++++++- pkg/workflow/label_names_test.go | 14 +++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/pkg/workflow/frontmatter_extraction_yaml.go b/pkg/workflow/frontmatter_extraction_yaml.go index 6db40dfa032..400c5559b35 100644 --- a/pkg/workflow/frontmatter_extraction_yaml.go +++ b/pkg/workflow/frontmatter_extraction_yaml.go @@ -101,7 +101,7 @@ func (c *Compiler) extractTopLevelYAMLSection(frontmatter map[string]any, key st return yamlStr } -// commentOutProcessedFieldsInOnSection comments out draft, fork, forks, names, manual-approval, stop-after, skip-if-match, skip-if-no-match, skip-roles, reaction, lock-for-agent, steps, permissions, and stale-check fields in the on section +// commentOutProcessedFieldsInOnSection comments out draft, fork, forks, names, labels, manual-approval, stop-after, skip-if-match, skip-if-no-match, skip-roles, reaction, lock-for-agent, steps, permissions, and stale-check fields in the on section // These fields are processed separately and should be commented for documentation // Exception: names fields in sections with __gh_aw_native_label_filter__ marker in frontmatter are NOT commented out func (c *Compiler) commentOutProcessedFieldsInOnSection(yamlStr string, frontmatter map[string]any) string { @@ -143,6 +143,7 @@ func (c *Compiler) commentOutProcessedFieldsInOnSection(yamlStr string, frontmat inSkipBotsArray := false inRolesArray := false inBotsArray := false + inLabelsArray := false inGitHubApp := false inOnSteps := false inOnPermissions := false @@ -290,6 +291,12 @@ func (c *Compiler) commentOutProcessedFieldsInOnSection(yamlStr string, frontmat inBotsArray = true } + // Check if we're entering labels array + if !inPullRequest && !inIssues && !inDiscussion && !inIssueComment && strings.HasPrefix(trimmedLine, "labels:") { + // Check if this is an array (next line will be "- ") or inline value + inLabelsArray = true + } + // Check if we're entering on.steps array if !inPullRequest && !inIssues && !inDiscussion && !inIssueComment && strings.HasPrefix(trimmedLine, "steps:") { inOnSteps = true @@ -444,6 +451,17 @@ func (c *Compiler) commentOutProcessedFieldsInOnSection(yamlStr string, frontmat } } + // Check if we're leaving the labels array by encountering another top-level field + if inLabelsArray && strings.TrimSpace(line) != "" { + // Get the indentation of the current line + lineIndent := len(line) - len(strings.TrimLeft(line, " \t")) + + // If this is a non-dash line at the same level as labels (2 spaces), we're out of the array + if lineIndent == 2 && !strings.HasPrefix(trimmedLine, "-") && !strings.HasPrefix(trimmedLine, "labels:") && !strings.HasPrefix(trimmedLine, "#") { + inLabelsArray = false + } + } + // Check if we're leaving the on.steps array by encountering another top-level field if inOnSteps && strings.TrimSpace(line) != "" { lineIndent := len(line) - len(strings.TrimLeft(line, " \t")) @@ -524,6 +542,13 @@ func (c *Compiler) commentOutProcessedFieldsInOnSection(yamlStr string, frontmat // Comment out array items in bots shouldComment = true commentReason = " # Bots processed as bot check in pre-activation job" + } else if strings.HasPrefix(trimmedLine, "labels:") { + shouldComment = true + commentReason = " # Label filtering applied via job conditions" + } else if inLabelsArray && strings.HasPrefix(trimmedLine, "-") { + // Comment out array items in labels + shouldComment = true + commentReason = " # Label filtering applied via job conditions" } else if strings.HasPrefix(trimmedLine, "steps:") { shouldComment = true commentReason = " # Steps injected into pre-activation job" diff --git a/pkg/workflow/label_names_test.go b/pkg/workflow/label_names_test.go index b1ebadf977a..f740a08db98 100644 --- a/pkg/workflow/label_names_test.go +++ b/pkg/workflow/label_names_test.go @@ -114,6 +114,7 @@ func TestLabelNamesPreActivationFilter(t *testing.T) { frontmatter string expectedIf string shouldHaveIf bool + labelItems []string }{ { name: "pull_request_target with single labels", @@ -135,6 +136,7 @@ tools: ---`, expectedIf: "github.event.label == null || github.event.label.name == 'panel-review'", shouldHaveIf: true, + labelItems: []string{"panel-review"}, }, { name: "pull_request_target with multiple labels", @@ -156,6 +158,7 @@ tools: ---`, expectedIf: "github.event.label == null || github.event.label.name == 'panel-review' || github.event.label.name == 'needs-triage'", shouldHaveIf: true, + labelItems: []string{"panel-review", "needs-triage"}, }, { // Negative test: no on.labels specified → the label-filter condition should not appear. @@ -199,6 +202,7 @@ tools: ---`, expectedIf: "github.event.label == null || github.event.label.name == 'bug' || github.event.label.name == 'enhancement'", shouldHaveIf: true, + labelItems: []string{"bug", "enhancement"}, }, } @@ -223,6 +227,16 @@ tools: if tt.shouldHaveIf { assert.Contains(t, lockContent, tt.expectedIf, "pre_activation job should have if condition matching label filter") + assert.Contains(t, lockContent, "# labels:", + "on.labels should be commented out in generated workflow") + assert.Contains(t, lockContent, "Label filtering applied via job conditions", + "on.labels comment should explain filter handling") + for _, item := range tt.labelItems { + if strings.Contains(tt.frontmatter, "labels: [") { + assert.Contains(t, lockContent, "# - "+item, + "on.labels array items should be commented out in generated workflow") + } + } } else { assert.NotContains(t, lockContent, tt.expectedIf, "pre_activation job should not have label-name if condition when labels not specified") From b9a1aac0136b11ff548fe4dd568a13164f6ef870 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 11 May 2026 04:39:50 +0000 Subject: [PATCH 03/12] Refine on.labels array detection and test assertions Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/workflow/frontmatter_extraction_yaml.go | 2 +- pkg/workflow/label_names_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/workflow/frontmatter_extraction_yaml.go b/pkg/workflow/frontmatter_extraction_yaml.go index 400c5559b35..e258b729782 100644 --- a/pkg/workflow/frontmatter_extraction_yaml.go +++ b/pkg/workflow/frontmatter_extraction_yaml.go @@ -292,7 +292,7 @@ func (c *Compiler) commentOutProcessedFieldsInOnSection(yamlStr string, frontmat } // Check if we're entering labels array - if !inPullRequest && !inIssues && !inDiscussion && !inIssueComment && strings.HasPrefix(trimmedLine, "labels:") { + if !inPullRequest && !inIssues && !inDiscussion && !inIssueComment && trimmedLine == "labels:" { // Check if this is an array (next line will be "- ") or inline value inLabelsArray = true } diff --git a/pkg/workflow/label_names_test.go b/pkg/workflow/label_names_test.go index f740a08db98..cb270ebb374 100644 --- a/pkg/workflow/label_names_test.go +++ b/pkg/workflow/label_names_test.go @@ -232,7 +232,7 @@ tools: assert.Contains(t, lockContent, "Label filtering applied via job conditions", "on.labels comment should explain filter handling") for _, item := range tt.labelItems { - if strings.Contains(tt.frontmatter, "labels: [") { + if len(tt.labelItems) > 1 { assert.Contains(t, lockContent, "# - "+item, "on.labels array items should be commented out in generated workflow") } From 905e5afd566f150d2720b20dc54a236f4c8ee07f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 11 May 2026 04:40:44 +0000 Subject: [PATCH 04/12] Clarify labels array-item expectations in tests Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/workflow/label_names_test.go | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/pkg/workflow/label_names_test.go b/pkg/workflow/label_names_test.go index cb270ebb374..84309638860 100644 --- a/pkg/workflow/label_names_test.go +++ b/pkg/workflow/label_names_test.go @@ -110,11 +110,12 @@ func TestLabelNamesPreActivationFilter(t *testing.T) { compiler := NewCompiler() tests := []struct { - name string - frontmatter string - expectedIf string - shouldHaveIf bool - labelItems []string + name string + frontmatter string + expectedIf string + shouldHaveIf bool + expectLabelArrayItems bool + labelItems []string }{ { name: "pull_request_target with single labels", @@ -136,7 +137,8 @@ tools: ---`, expectedIf: "github.event.label == null || github.event.label.name == 'panel-review'", shouldHaveIf: true, - labelItems: []string{"panel-review"}, + labelItems: []string{"panel-review"}, + expectLabelArrayItems: false, }, { name: "pull_request_target with multiple labels", @@ -158,7 +160,8 @@ tools: ---`, expectedIf: "github.event.label == null || github.event.label.name == 'panel-review' || github.event.label.name == 'needs-triage'", shouldHaveIf: true, - labelItems: []string{"panel-review", "needs-triage"}, + labelItems: []string{"panel-review", "needs-triage"}, + expectLabelArrayItems: true, }, { // Negative test: no on.labels specified → the label-filter condition should not appear. @@ -202,7 +205,8 @@ tools: ---`, expectedIf: "github.event.label == null || github.event.label.name == 'bug' || github.event.label.name == 'enhancement'", shouldHaveIf: true, - labelItems: []string{"bug", "enhancement"}, + labelItems: []string{"bug", "enhancement"}, + expectLabelArrayItems: true, }, } @@ -231,8 +235,8 @@ tools: "on.labels should be commented out in generated workflow") assert.Contains(t, lockContent, "Label filtering applied via job conditions", "on.labels comment should explain filter handling") - for _, item := range tt.labelItems { - if len(tt.labelItems) > 1 { + if tt.expectLabelArrayItems { + for _, item := range tt.labelItems { assert.Contains(t, lockContent, "# - "+item, "on.labels array items should be commented out in generated workflow") } From f5310f268b4af5f1bdd6667c0d82cba33ada6efb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 11 May 2026 04:41:40 +0000 Subject: [PATCH 05/12] Tidy labels filter test naming and inline comments Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/workflow/frontmatter_extraction_yaml.go | 1 - pkg/workflow/label_names_test.go | 18 +++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/pkg/workflow/frontmatter_extraction_yaml.go b/pkg/workflow/frontmatter_extraction_yaml.go index e258b729782..beacd695e92 100644 --- a/pkg/workflow/frontmatter_extraction_yaml.go +++ b/pkg/workflow/frontmatter_extraction_yaml.go @@ -293,7 +293,6 @@ func (c *Compiler) commentOutProcessedFieldsInOnSection(yamlStr string, frontmat // Check if we're entering labels array if !inPullRequest && !inIssues && !inDiscussion && !inIssueComment && trimmedLine == "labels:" { - // Check if this is an array (next line will be "- ") or inline value inLabelsArray = true } diff --git a/pkg/workflow/label_names_test.go b/pkg/workflow/label_names_test.go index 84309638860..58d1e120895 100644 --- a/pkg/workflow/label_names_test.go +++ b/pkg/workflow/label_names_test.go @@ -114,8 +114,8 @@ func TestLabelNamesPreActivationFilter(t *testing.T) { frontmatter string expectedIf string shouldHaveIf bool - expectLabelArrayItems bool - labelItems []string + shouldCheckLabelArrayItems bool + labelItems []string }{ { name: "pull_request_target with single labels", @@ -137,8 +137,8 @@ tools: ---`, expectedIf: "github.event.label == null || github.event.label.name == 'panel-review'", shouldHaveIf: true, - labelItems: []string{"panel-review"}, - expectLabelArrayItems: false, + labelItems: []string{"panel-review"}, + shouldCheckLabelArrayItems: false, }, { name: "pull_request_target with multiple labels", @@ -160,8 +160,8 @@ tools: ---`, expectedIf: "github.event.label == null || github.event.label.name == 'panel-review' || github.event.label.name == 'needs-triage'", shouldHaveIf: true, - labelItems: []string{"panel-review", "needs-triage"}, - expectLabelArrayItems: true, + labelItems: []string{"panel-review", "needs-triage"}, + shouldCheckLabelArrayItems: true, }, { // Negative test: no on.labels specified → the label-filter condition should not appear. @@ -205,8 +205,8 @@ tools: ---`, expectedIf: "github.event.label == null || github.event.label.name == 'bug' || github.event.label.name == 'enhancement'", shouldHaveIf: true, - labelItems: []string{"bug", "enhancement"}, - expectLabelArrayItems: true, + labelItems: []string{"bug", "enhancement"}, + shouldCheckLabelArrayItems: true, }, } @@ -235,7 +235,7 @@ tools: "on.labels should be commented out in generated workflow") assert.Contains(t, lockContent, "Label filtering applied via job conditions", "on.labels comment should explain filter handling") - if tt.expectLabelArrayItems { + if tt.shouldCheckLabelArrayItems { for _, item := range tt.labelItems { assert.Contains(t, lockContent, "# - "+item, "on.labels array items should be commented out in generated workflow") From b87e5417cc3d73be484f1e979b859b1fea023616 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 11 May 2026 06:10:02 +0000 Subject: [PATCH 06/12] Plan addressing PR comments Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .github/workflows/issue-monster.lock.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/issue-monster.lock.yml b/.github/workflows/issue-monster.lock.yml index 2d3dc4ad71f..182901c0d85 100644 --- a/.github/workflows/issue-monster.lock.yml +++ b/.github/workflows/issue-monster.lock.yml @@ -389,7 +389,7 @@ name: "Issue Monster" # return { # number: issue.number, # title: issue.title, - # labels: issue.labels.map(l => l.name), + # labels: issue.labels.map(l => l.name), # Label filtering applied via job conditions # body: issue.body, # created_at: issue.created_at, # score From 4f86a83d8c31a0469448108b95534b61b1dea7d5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 11 May 2026 06:14:14 +0000 Subject: [PATCH 07/12] Guard top-level on.labels handling from nested labels keys Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/workflow/frontmatter_extraction_yaml.go | 7 ++- pkg/workflow/label_names_test.go | 54 +++++++++++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/pkg/workflow/frontmatter_extraction_yaml.go b/pkg/workflow/frontmatter_extraction_yaml.go index beacd695e92..13f82bc39fe 100644 --- a/pkg/workflow/frontmatter_extraction_yaml.go +++ b/pkg/workflow/frontmatter_extraction_yaml.go @@ -253,6 +253,7 @@ func (c *Compiler) commentOutProcessedFieldsInOnSection(yamlStr string, frontmat } trimmedLine := strings.TrimSpace(line) + lineIndent := len(line) - len(strings.TrimLeft(line, " \t")) // Skip marker lines in the YAML output if (inPullRequest || inIssues || inDiscussion || inIssueComment) && strings.Contains(trimmedLine, "__gh_aw_native_label_filter__:") { @@ -292,7 +293,9 @@ func (c *Compiler) commentOutProcessedFieldsInOnSection(yamlStr string, frontmat } // Check if we're entering labels array - if !inPullRequest && !inIssues && !inDiscussion && !inIssueComment && trimmedLine == "labels:" { + if !inPullRequest && !inIssues && !inDiscussion && !inIssueComment && + !inOnSteps && !inOnPermissions && + lineIndent == 2 && trimmedLine == "labels:" { inLabelsArray = true } @@ -541,7 +544,7 @@ func (c *Compiler) commentOutProcessedFieldsInOnSection(yamlStr string, frontmat // Comment out array items in bots shouldComment = true commentReason = " # Bots processed as bot check in pre-activation job" - } else if strings.HasPrefix(trimmedLine, "labels:") { + } else if !inOnSteps && !inOnPermissions && lineIndent == 2 && strings.HasPrefix(trimmedLine, "labels:") { shouldComment = true commentReason = " # Label filtering applied via job conditions" } else if inLabelsArray && strings.HasPrefix(trimmedLine, "-") { diff --git a/pkg/workflow/label_names_test.go b/pkg/workflow/label_names_test.go index 58d1e120895..9444675c656 100644 --- a/pkg/workflow/label_names_test.go +++ b/pkg/workflow/label_names_test.go @@ -248,3 +248,57 @@ tools: }) } } + +func TestLabelNamesDoesNotAffectNestedOnStepsLabels(t *testing.T) { + tmpDir := testutil.TempDir(t, "labels-nested-steps-test") + compiler := NewCompiler() + + frontmatter := `--- +on: + issues: + types: [labeled] + labels: bug + steps: + - name: Nested labels in step input + uses: actions/github-script@v8 + with: + labels: + - triage + - needs-info + script: | + core.info('label') + +permissions: + contents: read + issues: read + pull-requests: read + +strict: false +tools: + github: + allowed: [issue_read] +---` + + testFile := tmpDir + "/test-nested-labels.md" + content := frontmatter + "\n\n# Test Workflow\n\nNested labels in on.steps should not be treated as on.labels." + require.NoError(t, os.WriteFile(testFile, []byte(content), 0644), "should write test file") + + err := compiler.CompileWorkflow(testFile) + require.NoError(t, err, "should compile workflow successfully") + + lockFile := stringutil.MarkdownToLockFile(testFile) + lockBytes, err := os.ReadFile(lockFile) + require.NoError(t, err, "should read lock file") + lockContent := string(lockBytes) + + // Clean up + os.Remove(testFile) + os.Remove(lockFile) + + assert.Equal(t, 1, strings.Count(lockContent, "Label filtering applied via job conditions"), + "only top-level on.labels should receive label-filter annotation") + assert.NotContains(t, lockContent, "- name: Nested labels in step input # Label filtering applied via job conditions", + "on.steps list items should not be annotated as label filtering") + assert.NotContains(t, lockContent, "- triage # Label filtering applied via job conditions", + "nested labels in on.steps should not be annotated as top-level label filtering") +} From 642b76252eb8bf663a76b273b228e1c353e5e59f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 11 May 2026 06:17:57 +0000 Subject: [PATCH 08/12] Tighten nested labels regression test cleanup and messaging Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/workflow/label_names_test.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pkg/workflow/label_names_test.go b/pkg/workflow/label_names_test.go index 9444675c656..f7d9500a66f 100644 --- a/pkg/workflow/label_names_test.go +++ b/pkg/workflow/label_names_test.go @@ -282,6 +282,7 @@ tools: testFile := tmpDir + "/test-nested-labels.md" content := frontmatter + "\n\n# Test Workflow\n\nNested labels in on.steps should not be treated as on.labels." require.NoError(t, os.WriteFile(testFile, []byte(content), 0644), "should write test file") + defer os.Remove(testFile) err := compiler.CompileWorkflow(testFile) require.NoError(t, err, "should compile workflow successfully") @@ -289,14 +290,11 @@ tools: lockFile := stringutil.MarkdownToLockFile(testFile) lockBytes, err := os.ReadFile(lockFile) require.NoError(t, err, "should read lock file") + defer os.Remove(lockFile) lockContent := string(lockBytes) - // Clean up - os.Remove(testFile) - os.Remove(lockFile) - assert.Equal(t, 1, strings.Count(lockContent, "Label filtering applied via job conditions"), - "only top-level on.labels should receive label-filter annotation") + "label-filter annotation should appear exactly once for top-level on.labels") assert.NotContains(t, lockContent, "- name: Nested labels in step input # Label filtering applied via job conditions", "on.steps list items should not be annotated as label filtering") assert.NotContains(t, lockContent, "- triage # Label filtering applied via job conditions", From 11ed60941db0b278a58ec72e0416d20f88e338e4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 11 May 2026 10:43:25 +0000 Subject: [PATCH 09/12] Add fuzz tests for on.labels comment-out behavior Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .../frontmatter_extraction_yaml_fuzz_test.go | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 pkg/workflow/frontmatter_extraction_yaml_fuzz_test.go diff --git a/pkg/workflow/frontmatter_extraction_yaml_fuzz_test.go b/pkg/workflow/frontmatter_extraction_yaml_fuzz_test.go new file mode 100644 index 00000000000..212436d3c5b --- /dev/null +++ b/pkg/workflow/frontmatter_extraction_yaml_fuzz_test.go @@ -0,0 +1,91 @@ +//go:build !integration + +package workflow + +import ( + "fmt" + "strconv" + "strings" + "testing" +) + +func FuzzCommentOutProcessedFieldsInOnSectionTopLevelLabels(f *testing.F) { + f.Add("bug", "enhancement", "triage", "needs-info") + f.Add("panel-review", "can't-repro", "nested-1", "nested-2") + f.Add("", "", "", "") + + compiler := NewCompiler() + f.Fuzz(func(t *testing.T, topA, topB, nestedA, nestedB string) { + topAQuoted := strconv.Quote(topA) + topBQuoted := strconv.Quote(topB) + nestedAQuoted := strconv.Quote(nestedA) + nestedBQuoted := strconv.Quote(nestedB) + + yamlStr := fmt.Sprintf(`on: + issues: + types: [labeled] + labels: + - %s + - %s + steps: + - name: Nested labels in step input + uses: actions/github-script@v8 + with: + labels: + - %s + - %s + script: | + core.info('label') +`, topAQuoted, topBQuoted, nestedAQuoted, nestedBQuoted) + + result := compiler.commentOutProcessedFieldsInOnSection(yamlStr, map[string]any{}) + + assertContains := func(expected string) { + if !strings.Contains(result, expected) { + t.Fatalf("expected %q in result:\n%s", expected, result) + } + } + + assertContains(" # labels: # Label filtering applied via job conditions") + assertContains("# - " + topAQuoted + " # Label filtering applied via job conditions") + assertContains("# - " + topBQuoted + " # Label filtering applied via job conditions") + + if got := strings.Count(result, "Label filtering applied via job conditions"); got != 3 { + t.Fatalf("expected 3 label-filter annotations (labels key + 2 items), got %d:\n%s", got, result) + } + }) +} + +func FuzzCommentOutProcessedFieldsInOnSectionNoTopLevelLabels(f *testing.F) { + f.Add("triage", "needs-info") + f.Add("", "") + + compiler := NewCompiler() + f.Fuzz(func(t *testing.T, nestedA, nestedB string) { + nestedAQuoted := strconv.Quote(nestedA) + nestedBQuoted := strconv.Quote(nestedB) + + yamlStr := fmt.Sprintf(`on: + issues: + types: [labeled] + steps: + - name: Nested labels in step input + uses: actions/github-script@v8 + with: + labels: + - %s + - %s + script: | + core.info('label') +`, nestedAQuoted, nestedBQuoted) + + result := compiler.commentOutProcessedFieldsInOnSection(yamlStr, map[string]any{}) + + if strings.Contains(result, "Label filtering applied via job conditions") { + t.Fatalf("unexpected top-level label filter annotation without on.labels:\n%s", result) + } + if got := strings.Count(result, "Label filtering applied via job conditions"); got != 0 { + t.Fatalf("unexpected top-level label filter annotations without on.labels (got %d):\n%s", got, result) + } + }) +} From 4a5b1d9d26e60d255b5e2e1eb0546d22a9c35da0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 11 May 2026 10:45:26 +0000 Subject: [PATCH 10/12] Refine label comment-out fuzz assertions Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .../frontmatter_extraction_yaml_fuzz_test.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pkg/workflow/frontmatter_extraction_yaml_fuzz_test.go b/pkg/workflow/frontmatter_extraction_yaml_fuzz_test.go index 212436d3c5b..5e192e2cc6a 100644 --- a/pkg/workflow/frontmatter_extraction_yaml_fuzz_test.go +++ b/pkg/workflow/frontmatter_extraction_yaml_fuzz_test.go @@ -49,9 +49,18 @@ func FuzzCommentOutProcessedFieldsInOnSectionTopLevelLabels(f *testing.F) { assertContains(" # labels: # Label filtering applied via job conditions") assertContains("# - " + topAQuoted + " # Label filtering applied via job conditions") assertContains("# - " + topBQuoted + " # Label filtering applied via job conditions") + assertContains(" # - " + nestedAQuoted) + assertContains(" # - " + nestedBQuoted) + if strings.Contains(result, " # - "+nestedAQuoted+" # Label filtering applied via job conditions") { + t.Fatalf("nested labels item should not be marked as top-level label filtering:\n%s", result) + } + if strings.Contains(result, " # - "+nestedBQuoted+" # Label filtering applied via job conditions") { + t.Fatalf("nested labels item should not be marked as top-level label filtering:\n%s", result) + } - if got := strings.Count(result, "Label filtering applied via job conditions"); got != 3 { - t.Fatalf("expected 3 label-filter annotations (labels key + 2 items), got %d:\n%s", got, result) + expectedLabelFilterAnnotations := len([]string{topAQuoted, topBQuoted}) + 1 // labels key + top-level items + if got := strings.Count(result, "Label filtering applied via job conditions"); got != expectedLabelFilterAnnotations { + t.Fatalf("expected %d label-filter annotations (labels key + top-level items), got %d:\n%s", expectedLabelFilterAnnotations, got, result) } }) } @@ -81,6 +90,12 @@ func FuzzCommentOutProcessedFieldsInOnSectionNoTopLevelLabels(f *testing.F) { result := compiler.commentOutProcessedFieldsInOnSection(yamlStr, map[string]any{}) + if !strings.Contains(result, " # - "+nestedAQuoted) { + t.Fatalf("expected nested labels item to remain in on.steps output:\n%s", result) + } + if !strings.Contains(result, " # - "+nestedBQuoted) { + t.Fatalf("expected nested labels item to remain in on.steps output:\n%s", result) + } if strings.Contains(result, "Label filtering applied via job conditions") { t.Fatalf("unexpected top-level label filter annotation without on.labels:\n%s", result) } From b210d26531272ac708d001b49fb0b9883792f52b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 11 May 2026 10:46:14 +0000 Subject: [PATCH 11/12] Polish fuzz test assertions Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/workflow/frontmatter_extraction_yaml_fuzz_test.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkg/workflow/frontmatter_extraction_yaml_fuzz_test.go b/pkg/workflow/frontmatter_extraction_yaml_fuzz_test.go index 5e192e2cc6a..57a59001512 100644 --- a/pkg/workflow/frontmatter_extraction_yaml_fuzz_test.go +++ b/pkg/workflow/frontmatter_extraction_yaml_fuzz_test.go @@ -58,7 +58,7 @@ func FuzzCommentOutProcessedFieldsInOnSectionTopLevelLabels(f *testing.F) { t.Fatalf("nested labels item should not be marked as top-level label filtering:\n%s", result) } - expectedLabelFilterAnnotations := len([]string{topAQuoted, topBQuoted}) + 1 // labels key + top-level items + expectedLabelFilterAnnotations := 3 // labels key + 2 top-level items if got := strings.Count(result, "Label filtering applied via job conditions"); got != expectedLabelFilterAnnotations { t.Fatalf("expected %d label-filter annotations (labels key + top-level items), got %d:\n%s", expectedLabelFilterAnnotations, got, result) } @@ -99,8 +99,5 @@ func FuzzCommentOutProcessedFieldsInOnSectionNoTopLevelLabels(f *testing.F) { if strings.Contains(result, "Label filtering applied via job conditions") { t.Fatalf("unexpected top-level label filter annotation without on.labels:\n%s", result) } - if got := strings.Count(result, "Label filtering applied via job conditions"); got != 0 { - t.Fatalf("unexpected top-level label filter annotations without on.labels (got %d):\n%s", got, result) - } }) } From 1f3d5995b36c2b76dd799302060e4f8947867f75 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 11 May 2026 10:47:17 +0000 Subject: [PATCH 12/12] Improve fuzz test clarity Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .../frontmatter_extraction_yaml_fuzz_test.go | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/pkg/workflow/frontmatter_extraction_yaml_fuzz_test.go b/pkg/workflow/frontmatter_extraction_yaml_fuzz_test.go index 57a59001512..b51c1c4c609 100644 --- a/pkg/workflow/frontmatter_extraction_yaml_fuzz_test.go +++ b/pkg/workflow/frontmatter_extraction_yaml_fuzz_test.go @@ -15,11 +15,11 @@ func FuzzCommentOutProcessedFieldsInOnSectionTopLevelLabels(f *testing.F) { f.Add("", "", "", "") compiler := NewCompiler() - f.Fuzz(func(t *testing.T, topA, topB, nestedA, nestedB string) { - topAQuoted := strconv.Quote(topA) - topBQuoted := strconv.Quote(topB) - nestedAQuoted := strconv.Quote(nestedA) - nestedBQuoted := strconv.Quote(nestedB) + f.Fuzz(func(t *testing.T, topLevelLabelA, topLevelLabelB, nestedLabelA, nestedLabelB string) { + topAQuoted := strconv.Quote(topLevelLabelA) + topBQuoted := strconv.Quote(topLevelLabelB) + nestedAQuoted := strconv.Quote(nestedLabelA) + nestedBQuoted := strconv.Quote(nestedLabelB) yamlStr := fmt.Sprintf(`on: issues: @@ -40,17 +40,17 @@ func FuzzCommentOutProcessedFieldsInOnSectionTopLevelLabels(f *testing.F) { result := compiler.commentOutProcessedFieldsInOnSection(yamlStr, map[string]any{}) - assertContains := func(expected string) { + mustContain := func(expected string) { if !strings.Contains(result, expected) { t.Fatalf("expected %q in result:\n%s", expected, result) } } - assertContains(" # labels: # Label filtering applied via job conditions") - assertContains("# - " + topAQuoted + " # Label filtering applied via job conditions") - assertContains("# - " + topBQuoted + " # Label filtering applied via job conditions") - assertContains(" # - " + nestedAQuoted) - assertContains(" # - " + nestedBQuoted) + mustContain(" # labels: # Label filtering applied via job conditions") + mustContain("# - " + topAQuoted + " # Label filtering applied via job conditions") + mustContain("# - " + topBQuoted + " # Label filtering applied via job conditions") + mustContain(" # - " + nestedAQuoted) + mustContain(" # - " + nestedBQuoted) if strings.Contains(result, " # - "+nestedAQuoted+" # Label filtering applied via job conditions") { t.Fatalf("nested labels item should not be marked as top-level label filtering:\n%s", result) } @@ -58,7 +58,8 @@ func FuzzCommentOutProcessedFieldsInOnSectionTopLevelLabels(f *testing.F) { t.Fatalf("nested labels item should not be marked as top-level label filtering:\n%s", result) } - expectedLabelFilterAnnotations := 3 // labels key + 2 top-level items + expectedTopLevelLabelItems := 2 + expectedLabelFilterAnnotations := expectedTopLevelLabelItems + 1 // labels key + top-level items if got := strings.Count(result, "Label filtering applied via job conditions"); got != expectedLabelFilterAnnotations { t.Fatalf("expected %d label-filter annotations (labels key + top-level items), got %d:\n%s", expectedLabelFilterAnnotations, got, result) }