Skip to content

Comment out top-level on.labels in compiled workflows to prevent push-time workflow parse failures#31411

Merged
pelikhan merged 12 commits into
mainfrom
copilot/fix-labels-filter-push-failure
May 11, 2026
Merged

Comment out top-level on.labels in compiled workflows to prevent push-time workflow parse failures#31411
pelikhan merged 12 commits into
mainfrom
copilot/fix-labels-filter-push-failure

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 11, 2026

  • Review new PR comments and identify actionable items
  • Add focused fuzz tests for frontmatter on.labels extraction/commenting behavior
  • Run targeted Go tests/fuzz-capable test execution for modified package
  • Run final validation and reply to the new PR comment

Copilot AI and others added 4 commits May 11, 2026 04:38
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix labels filter causing push-triggered runs to fail Comment out top-level on.labels in compiled workflows to prevent push-time workflow parse failures May 11, 2026
Copilot AI requested a review from pelikhan May 11, 2026 04:42
@pelikhan pelikhan marked this pull request as ready for review May 11, 2026 04:46
Copilot AI review requested due to automatic review settings May 11, 2026 04:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes GitHub Actions push-time workflow parse failures caused by emitting an invalid top-level on.labels key in compiled .lock.yml workflows by commenting out on.labels (and its list items) while preserving label filtering behavior via job-level if conditions.

Changes:

  • Updated commentOutProcessedFieldsInOnSection to comment out top-level on.labels and any multiline array items.
  • Extended label-name filter tests to assert that on.labels is emitted as commented documentation and list items are commented when applicable.
Show a summary per file
File Description
pkg/workflow/frontmatter_extraction_yaml.go Adds logic to comment out top-level on.labels (including multiline list items) in generated YAML.
pkg/workflow/label_names_test.go Adds assertions ensuring compiled workflows contain commented on.labels documentation and commented list items for label arrays.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comments suppressed due to low confidence (1)

pkg/workflow/frontmatter_extraction_yaml.go:550

  • The labels: comment-out branch matches any labels: key whenever we’re not in an event subsection. This can also hit nested labels: keys inside on.steps (or other nested objects) and annotate them as “Label filtering…”, even though they’re unrelated to on.labels. To avoid mis-commenting user-authored step configuration, restrict this to the top-level on.labels field (e.g., by checking lineIndent == 2 / strings.HasPrefix(line, " labels:"), and/or ensuring we’re not currently in inOnSteps / inOnPermissions).
			} 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"
  • Files reviewed: 2/2 changed files
  • Comments generated: 1

}

// Check if we're entering labels array
if !inPullRequest && !inIssues && !inDiscussion && !inIssueComment && trimmedLine == "labels:" {
@pelikhan
Copy link
Copy Markdown
Collaborator

@copilots review all comments

@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot review all
Comments

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

Hey @Copilot 👋 — great work fixing the on.labels push-time parse failure! The change to commentOutProcessedFieldsInOnSection is clean and targeted, and it's good to see tests updated in label_names_test.go to cover the new commenting behavior.

One small thing before this is ready for maintainer review:

  • Add a PR description — the body currently only contains an agent task checklist. A short prose summary (1–3 sentences) explaining what is being changed and why (i.e., that top-level on.labels causes GitHub's workflow parser to reject the compiled YAML at push time, and this fixes it by commenting those fields out) would help reviewers quickly understand the intent without digging into the diff.

If you'd like a hand, you can assign this prompt to your coding agent:

Update the PR body for PR #31411 in github/gh-aw to replace the agent task checklist with a concise prose description explaining:
1. What is changing: the workflow compiler's `commentOutProcessedFieldsInOnSection` function now comments out top-level `on.labels` (and its array items) in compiled `.lock.yml` files.
2. Why: GitHub's workflow parser rejects YAML with a top-level `on.labels` key at push time, causing failures; label filtering is already handled via job-level `if` conditions, so commenting out `labels:` in the compiled output is safe and correct.
Keep it to 3–5 sentences.

Generated by Contribution Check · ● 7.6M ·

Copilot AI and others added 2 commits May 11, 2026 06:14
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 11, 2026

@copilots review all comments

Addressed. I fixed the review-thread issue by restricting on.labels handling to true top-level on fields and excluding on.steps/on.permissions contexts (commit 4f86a83). I also added a regression test for nested labels inside on.steps, then tightened test cleanup/message quality (commit 642b762).

@copilot review all
Comments

Done — all actionable review comments have been addressed in 4f86a83 and follow-up test refinements in 642b762.

@github-actions github-actions Bot mentioned this pull request May 11, 2026
@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot add fuzz tests

Copilot AI and others added 4 commits May 11, 2026 10:43
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 11, 2026

@copilot add fuzz tests

Added fuzz tests in pkg/workflow/frontmatter_extraction_yaml_fuzz_test.go and pushed updates in commits 11ed609, 85d80f2, and 1f3d599.

They cover top-level on.labels comment-out behavior and nested on.steps labels: handling to prevent false label-filter annotations.

@pelikhan pelikhan merged commit f1d81d1 into main May 11, 2026
@pelikhan pelikhan deleted the copilot/fix-labels-filter-push-failure branch May 11, 2026 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

labels: filter causes push-triggered runs to fail instead of skip

3 participants