Skip to content

Add private endpoint to show github import errors

What does this MR do and why?

It adds private endpoint with paginated list of GitHub project import errors for each particular entity.

It is a second part for the GitHub importer: respond with detailed errors info. The first part - !114839 (merged).

Screenshots or screen recordings

If the importer failed to import a pull request If the importer failed to import a label
pull_request label
If the importer failed to import a protected branch If the importer failed to import a collaborator
protected_branch collaborator

Database

The new with_external_identifiers scope is added to the ImportFailure class.

Raw SQL:

SELECT
    "import_failures".*
FROM
    "import_failures"
WHERE
    "import_failures"."external_identifiers" != '{}'

How to set up and validate locally

(Can be validated when the first part is merged)

  1. Import a GitHub repo via UI (on the /import/github/status page) or GitLab API. Import has to finish with the Partial status (e.g. if the repo has an issue, raise an exception inside Gitlab::GithubImport::Importer::IssueImporter)
  2. Send GET request to {{host}}/import/github/failures with request body: { "project_id": 12345 } (Cookie has to be provided in the request headers)
  3. Check the response. In case the importer failed to import one issue, the response should look like this:
[
  {
     'type': 'issue',
     'title': 'Issue with a cool feature',
     'provider_url': 'https://github.com/OWNER/REPO/issues/1',
     'details:' {
       'exception_class': 'Some class',
       'exception_message': 'Something went wrong',
       'correlation_id_value': '69248b080100d8c15bf36cf74377f2be',
       'source': 'Gitlab::GithubImport::Importer::IssueAndLabelLinksImporter',
       'github_identifiers': {
         'iid': 2,
         'object_type': 'issue',
         'issuable_type': 'Issue'
       },
     'created_at': '2023-03-31T08:47:31.628Z'
  }
]

MR acceptance checklist

Edited by Peter Leitzen

Merge request reports