gh-gei icon indicating copy to clipboard operation
gh-gei copied to clipboard

Return a clear error message when the source repo for a GHES-to-GHEC migration doesn't exist

Open timrogers opened this issue 2 years ago • 0 comments

When the source repo doesn't exist for a GHES-to-GHEC migration, the migrate-repo command currently fails with a not very helpful error:

System.Net.Http.HttpRequestException: Response status code does not indicate success: 422 (Unprocessable Entity).

Under the hood, this happens because we call the "Start an organization migration" REST API, and the GitHub API responds like this:

422 Unprocessable Entity

{"message":"Validation Failed","errors":[{"resource":"Migration","field":"repositories","index":0,"code":"invalid_value"},{"resource":"Migration","field":"repositories","code":"missing_field"}],"documentation_url":"https://docs.github.com/enterprise/3.4/rest/reference/migrations#start-an-organization-migration"}

We should handle this case better. We could either:

  1. Add a check at the start of the migration, like the check we already have to ensure that the target repo doesn't exist, to check that the source repo exists
  2. Convert the above error returned by the REST API into a helpful error that tells you what the problem actually is

timrogers avatar Apr 18 '23 17:04 timrogers