Skip to content

[WIP] Fix PR label handling in sync-release.yml#61

Merged
agocke merged 2 commits intobazelfrom
copilot/fix-pr-labels-issue
Mar 13, 2026
Merged

[WIP] Fix PR label handling in sync-release.yml#61
agocke merged 2 commits intobazelfrom
copilot/fix-pr-labels-issue

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 13, 2026

Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.

Original prompt

Problem

The "Create PR" step in .github/workflows/sync-release.yml fails with:

Created PR: could not add label: 'bazel-sync' not found

even though the bazel-sync label exists in the repository. The root cause is that gh pr create --label does not support comma-separated labels. When the workflow passes --label "bazel-sync,bazel-sync-clean", the CLI interprets the entire string "bazel-sync,bazel-sync-clean" as a single label name, which doesn't exist.

Fix

In the file .github/workflows/sync-release.yml, in the "Create PR" step (around lines 156-191):

  1. Change the case block to set a label_flags variable with separate --label flags instead of a comma-separated labels string.
  2. Update the gh pr create call to use $label_flags (unquoted, so word-splitting produces separate arguments) instead of --label "$labels".

Before (lines 156-186):

          case "$classification" in
            clean)
              title="✅ Sync ${commit_short}: ${commit_subject}"
              labels="bazel-sync,bazel-sync-clean"
              ;;
            build-changes)
              title="⚠️ Sync ${commit_short}: ${commit_subject}"
              labels="bazel-sync,bazel-sync-needs-attention"
              ;;
            conflict)
              title="❌ Sync ${commit_short}: ${commit_subject}"
              labels="bazel-sync,bazel-sync-conflict"
              ;;
            *)
              title="Sync ${commit_short}: ${commit_subject}"
              labels="bazel-sync"
              ;;
          esac

          ...

          pr_url=$(gh pr create \
            --base bazel \
            --head "${{ steps.create-branch.outputs.branch }}" \
            --title "$title" \
            --body-file "$report_file" \
            --label "$labels" 2>&1 || true)

After:

          case "$classification" in
            clean)
              title="✅ Sync ${commit_short}: ${commit_subject}"
              label_flags="--label bazel-sync --label bazel-sync-clean"
              ;;
            build-changes)
              title="⚠️ Sync ${commit_short}: ${commit_subject}"
              label_flags="--label bazel-sync --label bazel-sync-needs-attention"
              ;;
            conflict)
              title="❌ Sync ${commit_short}: ${commit_subject}"
              label_flags="--label bazel-sync --label bazel-sync-conflict"
              ;;
            *)
              title="Sync ${commit_short}: ${commit_subject}"
              label_flags="--label bazel-sync"
              ;;
          esac

          ...

          pr_url=$(gh pr create \
            --base bazel \
            --head "${{ steps.create-branch.outputs.branch }}" \
            --title "$title" \
            --body-file "$report_file" \
            $label_flags 2>&1 || true)

Key points:

  • $label_flags must NOT be quoted in the gh pr create call so that bash word-splits it into separate arguments.
  • Only the case block variable assignment and the gh pr create line need to change. Everything else in the file stays the same.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: This gh action is failing even though i have a bazel-sync label in the repo: classification="clean"
report_file="/tmp/sync-report.md"
commit_subject="[release/10.0] Source code updates from dotnet/dotnet (dotnet#124136)"
commit_short="066be76ee5d"
remaining="18"

case "$classification" in
clean)
title="✅ Sync ${commit_short}: ${commit_subject}"
labels="bazel-sync,bazel-sync-clean"
;;
build-changes)
title="⚠️ Sync ${commit_short}: ${commit_subject}"
labels="bazel-sync,bazel-sync-needs-attention"
;;
conflict)
title="❌ Sync ${commit_short}: ${commit_subject}"
labels="bazel-sync,bazel-sync-conflict"
;;
*)
title="Sync ${commit_short}: ${commit_subject}"
labels="bazel-sync"
;;
esac

Prepend commit info to the report

commit_header="Upstream commit: `${commit_short}` — ${commit_subject}"
commit_header+="\nRemaining after this: $((remaining - 1)) commit(s)\n\n---\n\n"
full_body=$(printf '%s' "$commit_header" && cat "$report_file")
echo "$full_body" > "$report_file"

pr_url=$(gh pr create
--base bazel
--head "sync/release-10.0-066be76ee5d"
--title "$title"
--body-file "$report_file"
--label "$labels" 2>&1 || true)

Extract PR number from URL

pr_number=$(echo "$pr_url" | grep -oP '/pull/\K[0-9]+' || echo "")
echo "pr_number=$pr_number" >> "$GITHUB_OUTPUT"
echo "Created PR: $pr_url"
shell: /usr/bin/bash -e {0}
env:
GH_TOKEN: ***
Created PR: could not add label: 'bazel-sync' not found

Assistant: The issue is clear: the gh pr create --label "$labels" command is failing because the labels (bazel-sync, `bazel-sync-...

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Updated label handling in PR creation logic to use label_flags instead of labels.
@agocke agocke marked this pull request as ready for review March 13, 2026 23:40
@agocke agocke enabled auto-merge (squash) March 13, 2026 23:40
@agocke agocke disabled auto-merge March 13, 2026 23:40
@agocke agocke enabled auto-merge (squash) March 13, 2026 23:40
@agocke agocke merged commit eec0c6a into bazel Mar 13, 2026
4 checks passed
@agocke agocke deleted the copilot/fix-pr-labels-issue branch March 13, 2026 23:45
Copilot stopped work on behalf of agocke due to an error March 13, 2026 23:45
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.

2 participants