Skip to content

Open batch change changesets are not updated if the repo is archived while they're open

Created by: LawnGnome

Original source: https://sourcegraph.slack.com/archives/C02BJ8T258D/p1635458039067400

Steps to reproduce

  1. Create a batch change that publishes a changeset to repo X (the report is on GitHub, but I'd assume this is going to be true for all code hosts).
  2. Archive X on the code host, making it read only. All PRs are locked at this point.
  3. Observe that Batch Changes still thinks the PR is open, and the PR cannot be closed within the batch change.

Planned solution

Add a new terminal state that behaves like closed but is displayed differently to avoid confusion. (Name TBC, since we already have a concept of "archiving" that's different in Batch Changes.)

We need to be able to migrate both into and out of that state as repositories are archived and unarchived.

For now, we'll only do this on changeset sync or reconciler error, but an obvious future enhancement would be to also update changeset state when repo-updater becomes aware of a repo being archived or unarchived. (Indeed, Batch Changes could also update the repo once if it becomes aware before repo-updater.) The main technical challenge here is that it crosses the open source/enterprise boundary, and would probably need some new plumbing. (Maybe a notification queue via Redis on repo-updater events?)

Reconciler errors to handle

We want to detect useful errors in both the push and update operations. We'll probably have to do this the old fashioned way with string comparisons in most cases.

Code host On push On update
GitHub
ERROR: This repository was archived so it is read-only.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
{
  "data": {
    "updatePullRequest": null
  },
  "errors": [
    {
      "type": "UNPROCESSABLE",
      "path": [
        "updatePullRequest"
      ],
      "locations": [
        {
          "line": 314,
          "column": 3
        }
      ],
      "message": "Repository was archived so is read-only"
    }
  ]
}
GitLab
remote:
remote: ========================================================================
remote:
remote: ERROR: You are not allowed to push code to this project.
remote:
remote: ========================================================================
remote:
fatal: Could not read from remote repository.
403 Forbidden (no other useful message to disambiguate)
Bitbucket Server No concept of archiving a repo, or making it completely read only
Bitbucket Cloud