fix: push release PR updates via Git Data API instead of code-suggester#2774
Open
Kerwood wants to merge 3 commits into
Open
fix: push release PR updates via Git Data API instead of code-suggester#2774Kerwood wants to merge 3 commits into
Kerwood wants to merge 3 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Author
|
I believe this PR aligns well with the future plan to remove code-suggester as a dependency in this project, since it implements its own @chingor13 Any chance you've had time to look at this PR? |
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.
Fixes #2773
When
separate-pull-requests: trueis set, updating an existing release PR consistently fails with:The branch is updated successfully (
Updating reference heads/release-please--branches--main--components--<comp>), but the action exits non-zero.Reproduces on
release-please-action@v4and@v5, against library 17.3.0 and 17.6.0, with a GitHub App token.Root cause
GitHub.updatePullRequest(andLocalGitHub.updatePullRequest) was reusingcode-suggester.createPullRequestto do both the branch push and the PR refresh.code-suggesteralways:octokit.pulls.list({head})plus a strictpr.head.label === headfind,octokit.pulls.create.The lookup in step (2) is best-effort. It can miss the PR for several reasons, case-sensitivity differences between
repository.owner(sometimes lowercased through env-var paths likeGITHUB_REPOSITORY) and the org login as GitHub returns it inpr.head.label, the un-paginated single-page response, brief eventual consistency onpulls.list. When the lookup misses, step (3) runs and GitHub returns 422 because there's obviously already a PR for that branch.release-pleasealready knows the PR number it's updating,manifest.ts:1040matched the existing PR before callingupdatePullRequest. So the detect-or-create step is unnecessary work that can fail. Only the create path actually needs find-or-create semantics; the update path was misusingcode-suggester.The bug surfaces especially under
separate-pull-requests: truebecause each component's body diverges independently after a new commit, and every divergent body hits the update path.Fix
commitAndPushChanges(branch, message, changes)toGitHubApi. It uses the Git Data API directly:getRef → getCommit → createBlob (per file) → createTree → createCommit → updateRef --force. No PR detection. No PR create. Empty change sets are a no-op.GitHub.updatePullRequestandLocalGitHub.updatePullRequestnow callcommitAndPushChangesfollowed by the existinggitHubApi.updatePullRequest(number, title, body)PATCH.code-suggesteris no longer touched in the update path, sooctokit.pulls.createcannot be called and the 422 cannot occur, regardless of how the upstream lookup would have behaved.GitHub.createPullRequest) is unchanged. "Find-or-create" is the correct semantic there; only the reuse in the update path was wrong.Test plan
npm run compile, passesnpm run lint, clean (only pre-existing warnings in unrelated files)npm test, full suite (1101 tests) passesYou can test the fix by using my
release-please-actionfork.