Skip to content

fix: retry post-creation API calls on 422 to handle GitHub eventual consistency#4333

Open
dbeilin wants to merge 1 commit intopeter-evans:mainfrom
dbeilin:fix/retry-post-creation-422
Open

fix: retry post-creation API calls on 422 to handle GitHub eventual consistency#4333
dbeilin wants to merge 1 commit intopeter-evans:mainfrom
dbeilin:fix/retry-post-creation-422

Conversation

@dbeilin
Copy link

@dbeilin dbeilin commented Mar 18, 2026

Summary

  • Adds targeted retry logic for API calls made immediately after PR creation (labels, milestone, assignees, reviewers)
  • Retries only 422 errors, only when the PR was just created (pull.created === true), up to 2 retries with 1s delay
  • Does not change the global @octokit/plugin-retry configuration — this is scoped retry in the specific code path affected by GitHub API eventual consistency

Context

After creating a PR, follow-up REST API calls can fail with 422 Validation Failed: "Could not resolve to a node with the global id of '...'" because GitHub's API hasn't fully propagated the new PR internally. This is intermittent and timing-dependent.

Fixes #4321

Test plan

  • New unit tests for retryWithBackoff utility (5 tests)
  • All existing unit tests pass (17 total)
  • All integration tests pass (50 total)
  • npm run build succeeds

🤖 Generated with Claude Code

…onsistency

After creating a PR, follow-up API calls (labels, milestone, assignees,
reviewers) can fail with a 422 "Could not resolve to a node" error due
to GitHub API eventual consistency. This adds targeted retry logic that
only activates for newly created PRs, retrying 422 errors up to 2 times
with a 1-second delay between attempts.

Fixes peter-evans#4321

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dbeilin
Copy link
Author

dbeilin commented Mar 18, 2026

hi @peter-evans , this PR should address the label application issue.
It was 100% written by opus 4.6, hope that's not against your policy. Just thought I'd try, if you'd rather avoid implementing AI generated code, I totally understand.

Let me know if you have any concerns. We're using your Action in a lot of our workflows and have been experiencing that label apply issue pretty often.

Thanks

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.

Race condition: addLabels fails with 'Could not resolve to a node' immediately after PR creation

1 participant