Conversation
…ace condition GitHub's API can transiently fail to resolve a newly created PR's node ID when label operations are called immediately after PR creation. This caused the safe_outputs job to fall back to creating an issue instead of the PR (seen in run #23677438752 / issue #23316). The fix wraps addLabels in its own try-catch (non-fatal warning), consistent with how reviewer requests are already handled. A test is added to verify that a label failure does not trigger the fallback-to-issue path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Collaborator
|
…initial delay) Agent-Logs-Url: https://github.com/github/gh-aw/sessions/8c665314-60a8-42ae-8442-5b824d988f93 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Contributor
Done in 515aff8. |
…ases Agent-Logs-Url: https://github.com/github/gh-aw/sessions/8c665314-60a8-42ae-8442-5b824d988f93 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[q] fix: wrap addLabels in try-catch to prevent PR creation fallback on label race condition (#23316)
[q] fix: wrap addLabels in try-catch with exponential backoff retry to prevent PR creation fallback on label race condition (#23316)
Mar 28, 2026
pelikhan
approved these changes
Mar 28, 2026
| // Label addition is non-critical - warn but don't fail the PR creation. | ||
| // GitHub's API may transiently fail to resolve the PR node ID immediately | ||
| // after creation, which causes label operations to fail with an unprocessable error. | ||
| core.warning(`Failed to add labels to PR #${pullRequest.number}: ${labelError instanceof Error ? labelError.message : String(labelError)}`); |
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/0c60e56c-502b-4b8c-95d3-56dff8eb80ce Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root Cause (from live data)
Investigated run #23677438752 which triggered issue #23316.
Exact log sequence:
The bug: In
create_pull_request.cjs, theaddLabelsREST call was not wrapped in a try-catch. When it failed due to a GitHub API race condition (PR node ID not immediately resolvable after creation), the exception propagated to the outercatchblock, which misidentified it as a PR creation failure and triggered the fallback-to-issue path — even though the PR was already successfully created.The label failure error is a known GitHub API eventual consistency issue: the REST API internally uses GraphQL, and the newly created PR's node ID isn't immediately resolvable.
Changes
actions/setup/js/create_pull_request.cjsaddLabelsin its own try-catch — matching the existing pattern used forrequestReviewerswithRetryhelper fromerror_recovery.cjs: 3 retries, 3 s initial delay, ×2 multiplierisLabelTransientErrorpredicate that extends the standard transient-error check (isTransientError) to also match the specific PR node-ID race condition ("Could not resolve to a node with the global id")actions/setup/js/create_pull_request.test.cjsvi.useFakeTimers()/vi.runAllTimersAsync()so retry delays don't slow the suiteaddLabelsis called 4 times (1 initial + 3 retries) when all attempts fail"should succeed when addLabels recovers on a retry"— verifies success and only 2 calls when the second attempt succeeds"should not retry addLabels for non-transient errors"— verifies exactly 1 call for errors that are not retryableValidation
create_pull_request.test.cjs💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.