Skip to content

fix: retry post-creation API calls on 422 eventual consistency errors#4356

Merged
peter-evans merged 1 commit intomainfrom
422-post-create
Apr 10, 2026
Merged

fix: retry post-creation API calls on 422 eventual consistency errors#4356
peter-evans merged 1 commit intomainfrom
422-post-create

Conversation

@peter-evans
Copy link
Copy Markdown
Owner

Fixes #4321

Add retry logic to handle GitHub API eventual consistency errors that can occur after creating a new pull request. Follow-up API calls for milestones, labels, assignees, and reviewers may fail with a 422 "Could not resolve to a node" error before the PR is fully propagated.

  • Add generic retryWithBackoff helper in src/utils.ts with exponential backoff (default 2 retries, starting at 1s delay)
  • Wrap post-creation API calls in src/github-helper.ts with withRetryForNewPr(), which only retries for newly created PRs
  • Use @octokit/request-error RequestError type for precise error matching (status 422 + "Could not resolve to a node" message)
  • Add unit tests for retryWithBackoff covering success, retry, exhaustion, and non-retryable error scenarios
  • Update dist/index.js bundle and package.json dependencies

Add retry logic to handle GitHub API eventual consistency errors that
can occur after creating a new pull request. Follow-up API calls for
milestones, labels, assignees, and reviewers may fail with a 422
"Could not resolve to a node" error before the PR is fully propagated.

- Add generic `retryWithBackoff` helper in `src/utils.ts` with
  exponential backoff (default 2 retries, starting at 1s delay)
- Wrap post-creation API calls in `src/github-helper.ts` with
  `withRetryForNewPr()`, which only retries for newly created PRs
- Use `@octokit/request-error` `RequestError` type for precise error
  matching (status 422 + "Could not resolve to a node" message)
- Add unit tests for `retryWithBackoff` covering success, retry,
  exhaustion, and non-retryable error scenarios
- Update `dist/index.js` bundle and `package.json` dependencies
@github-actions
Copy link
Copy Markdown
Contributor

Full test suite slash command (repository admin only)

/test repository=peter-evans/create-pull-request ref=422-post-create build=true
/test repository=peter-evans/create-pull-request ref=422-post-create build=true sign-commits=true

@peter-evans
Copy link
Copy Markdown
Owner Author

peter-evans commented Apr 10, 2026

/test repository=peter-evans/create-pull-request ref=422-post-create build=true

Command run output

@peter-evans
Copy link
Copy Markdown
Owner Author

peter-evans commented Apr 10, 2026

/test repository=peter-evans/create-pull-request ref=422-post-create

Command run output

@peter-evans
Copy link
Copy Markdown
Owner Author

peter-evans commented Apr 10, 2026

/test repository=peter-evans/create-pull-request ref=422-post-create build=true sign-commits=true

Command run output

@peter-evans peter-evans merged commit 5f6978f into main Apr 10, 2026
6 checks passed
@peter-evans peter-evans deleted the 422-post-create branch April 10, 2026 16:24
renovate bot added a commit to sdwilsh/ansible-playbooks that referenced this pull request Apr 11, 2026
##### [\`v8.1.1\`](https://github.com/peter-evans/create-pull-request/releases/tag/v8.1.1)

#### What's Changed

- build(deps-dev): bump the npm group with 2 updates by [@dependabot](https://github.com/dependabot)\[bot] in [#4305](peter-evans/create-pull-request#4305)
- build(deps): bump minimatch by [@dependabot](https://github.com/dependabot)\[bot] in [#4311](peter-evans/create-pull-request#4311)
- build(deps): bump the github-actions group with 2 updates by [@dependabot](https://github.com/dependabot)\[bot] in [#4316](peter-evans/create-pull-request#4316)
- build(deps): bump [@tootallnate/once](https://github.com/tootallnate/once) and jest-environment-jsdom by [@dependabot](https://github.com/dependabot)\[bot] in [#4323](peter-evans/create-pull-request#4323)
- build(deps-dev): bump undici from 6.23.0 to 6.24.0 by [@dependabot](https://github.com/dependabot)\[bot] in [#4328](peter-evans/create-pull-request#4328)
- build(deps-dev): bump flatted from 3.3.1 to 3.4.2 by [@dependabot](https://github.com/dependabot)\[bot] in [#4334](peter-evans/create-pull-request#4334)
- build(deps): bump picomatch by [@dependabot](https://github.com/dependabot)\[bot] in [#4339](peter-evans/create-pull-request#4339)
- build(deps-dev): bump handlebars from 4.7.8 to 4.7.9 by [@dependabot](https://github.com/dependabot)\[bot] in [#4344](peter-evans/create-pull-request#4344)
- build(deps-dev): bump the npm group with 3 updates by [@dependabot](https://github.com/dependabot)\[bot] in [#4349](peter-evans/create-pull-request#4349)
- fix: retry post-creation API calls on 422 eventual consistency errors by [@peter-evans](https://github.com/peter-evans) in [#4356](peter-evans/create-pull-request#4356)

**Full Changelog**: <peter-evans/create-pull-request@v8.1.0...v8.1.1>
sdwilsh pushed a commit to sdwilsh/ansible-playbooks that referenced this pull request Apr 11, 2026
##### [\`v8.1.1\`](https://github.com/peter-evans/create-pull-request/releases/tag/v8.1.1)

#### What's Changed

- build(deps-dev): bump the npm group with 2 updates by [@dependabot](https://github.com/dependabot)\[bot] in [#4305](peter-evans/create-pull-request#4305)
- build(deps): bump minimatch by [@dependabot](https://github.com/dependabot)\[bot] in [#4311](peter-evans/create-pull-request#4311)
- build(deps): bump the github-actions group with 2 updates by [@dependabot](https://github.com/dependabot)\[bot] in [#4316](peter-evans/create-pull-request#4316)
- build(deps): bump [@tootallnate/once](https://github.com/tootallnate/once) and jest-environment-jsdom by [@dependabot](https://github.com/dependabot)\[bot] in [#4323](peter-evans/create-pull-request#4323)
- build(deps-dev): bump undici from 6.23.0 to 6.24.0 by [@dependabot](https://github.com/dependabot)\[bot] in [#4328](peter-evans/create-pull-request#4328)
- build(deps-dev): bump flatted from 3.3.1 to 3.4.2 by [@dependabot](https://github.com/dependabot)\[bot] in [#4334](peter-evans/create-pull-request#4334)
- build(deps): bump picomatch by [@dependabot](https://github.com/dependabot)\[bot] in [#4339](peter-evans/create-pull-request#4339)
- build(deps-dev): bump handlebars from 4.7.8 to 4.7.9 by [@dependabot](https://github.com/dependabot)\[bot] in [#4344](peter-evans/create-pull-request#4344)
- build(deps-dev): bump the npm group with 3 updates by [@dependabot](https://github.com/dependabot)\[bot] in [#4349](peter-evans/create-pull-request#4349)
- fix: retry post-creation API calls on 422 eventual consistency errors by [@peter-evans](https://github.com/peter-evans) in [#4356](peter-evans/create-pull-request#4356)

**Full Changelog**: <peter-evans/create-pull-request@v8.1.0...v8.1.1>
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