Skip to content

Version Packages PR not reopened after force push when using commitMode: "github-api" (regression since v1.8.0) #615

@p-chan

Description

@p-chan

Summary

Since v1.8.0, when using commitMode: "github-api", existing Version Packages PRs are sometimes not reopened after being closed by a force push.

Root Cause

This is a regression introduced by #258 (draft PR support), which changed the existing PR update logic from REST API to GraphQL.

v1.7.0 (REST API — worked correctly):

await octokit.rest.pulls.update({
  pull_number: pullRequest.number,
  title: finalPrTitle,
  body: prBody,
  ...github.context.repo,
  state: "open",
});

v1.8.0 (GraphQL — race condition):

await octokit.graphql(updatePullRequestMutation, {
  pullRequestId: pullRequest.node_id,
  title: finalPrTitle,
  body: prBody,
  // state: OPEN is set inside the mutation
});

With commitMode: "github-api", the action force-pushes the branch before calling the PR update. The force push causes GitHub to close the PR. However, when the GraphQL mutation runs immediately after, the GitHub API may still reflect the PR as "open" (due to propagation delay), making state: OPEN in the mutation a no-op. The PR then remains closed permanently.

Steps to Reproduce

  1. Use commitMode: "github-api" with changesets/action@v1 (= v1.8.0)
  2. Merge a PR to main → Version Packages PR is created ✅
  3. Merge another PR to main → action finds the existing Version Packages PR as open, logs updating found pull request #N, but the PR ends up closed and never reopened
  4. Manually rerunning the workflow reopens the PR correctly ✅

The failure occurs on the second run (when the PR was already opened once by the action). The first run that creates the PR works fine.

Environment

  • changesets/action@v1 (v1.8.0)
  • commitMode: "github-api"
  • Using a GitHub App token (instead of default GITHUB_TOKEN)
  • Standard GitHub (not GitHub Enterprise)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions