Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not update existing PR: A pull request already exists for #396

Open
edouardr opened this issue Aug 29, 2024 · 6 comments
Open

Does not update existing PR: A pull request already exists for #396

edouardr opened this issue Aug 29, 2024 · 6 comments

Comments

@edouardr
Copy link

Since the latest version (v1.4.8) I get an error when a changesets PR already exists.

see the output log

 delete mode 100644 .changeset/wise-nails-wave.md
 create mode 100644 apps/new_file.md
 create mode 100644 apps/my-package/CHANGELOG.md
 create mode 100644 packages/another-package/CHANGELOG.md
/usr/bin/git push origin HEAD:changeset-release/main --force
To https://github.com/MyOrg/MyRepo
 + 4cd5cdb...8c05ff1 HEAD -> changeset-release/main (forced update)
[]
creating pull request
Error: HttpError: Validation Failed: {"resource":"PullRequest","code":"custom","message":"A pull request already exists for MyOrg:changeset-release/main."}
Error: Validation Failed: {"resource":"PullRequest","code":"custom","message":"A pull request already exists for MyOrg:changeset-release/main."}

If we pay attention we can see that we have creating pull request instead of updating found pull request #A_NUMBER.

It seems this would have been introduced by this commit 48ab0d2, as we can see [] in the output just before.

This would come from:

/// src/run.ts l.381
 let existingPullRequests = await existingPullRequestsPromise;
  core.info(JSON.stringify(existingPullRequests.data, null, 2));
@Andarist
Copy link
Member

Cc @s0

@Andarist
Copy link
Member

Weirdly, I see pull requests to be updated just fine using the recent version, for example here.

If we take a close look we can see a lone [] a line above creating pull request. I believe this comes from this line:

core.info(JSON.stringify(existingPullRequests.data, null, 2));

So the response the action got to this request was, indeed, an empty array - indicating that there are no open PRs there. How many do u have? Could you try to programmatically query the same thing as here and report what result do u get back?

@s0
Copy link
Contributor

s0 commented Aug 29, 2024

Is there any chance that there were multiple workflows being run concurrently that interfered? And what happens when you try to re-run the workflow run, is it consistently doing the same thing?

Shot in the dark, but my current thoughts are:

  • Parallel attempts to create the PR with a race condition
  • Potential GitHub outage / inconsistency
  • Some interesting characters in the org name cause the ${github.context.repo.owner}:${versionBranch} construction to format weirdly?

One potential solution could be to just:

  • never check whether there's an existing PR
  • always attempt to create the PR
  • if the PR creation fails with "A pull request already exists", at that point try to get the PR number and try again.

@Andarist
Copy link
Member

One potential solution could be to just

OTOH, if this is a race condition this might be a good thing that it fails. It lets the user to correct their concurrency setting.

@edouardr
Copy link
Author

edouardr commented Sep 2, 2024

Hi guys!

Thanks for the answers. So to let you know, I reverted the action to this commit: aba318e

      - name: Create Release Pull Request or Publish to npm
        id: changesets
        uses: changesets/action@aba318e9165b45b7948c60273e0b72fce0a64eb9
        with:
          version: pnpm run ci:version
          commit: 'chore(twinops): update versions'
          title: 'chore(twinops): update versions'
          publish: pnpm run ci:publish
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NPM_TOKEN: ${{ secrets.GPR_ACCESS_TOKEN }}

This successfully updated the existing PR

 {
  "total_count": 1,
  "incomplete_results": false,
  "items": [
    {
    /// ...

updating found pull request #66

Tonight, I'll run

 let existingPullRequests = await existingPullRequestsPromise;
  core.info(JSON.stringify(existingPullRequests.data, null, 2));

To see what the result is.

@s0
Copy link
Contributor

s0 commented Oct 9, 2024

@edouardr what were the results of your findings?

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

No branches or pull requests

3 participants