GitHub Import failing with Object not found - no match for id (some_git_hash_here)
Summary
There are some corner cases that can be triggered when a branch in an early time gets rewritten and merged, and another branch with same name exists during the import.
As we currently verify for the existence of the object and the existence of the branch, but not for the existence of that object in the branch (and that tree).
This issue may or may not be entirely related to gitlab-org/gitlab-ce#29034 (happened to the same customer)
Steps to reproduce
This is hard to simulate and while we understand why this is happening we aren't able to create and example repository to make it fail. More details can be found on the zendesk ticket: https://gitlab.zendesk.com/agent/tickets/67647 (and see the discussion mentioned there in slack).
Some inspiration on how to get into an object not found in GitLab is described here: https://gitlab.com/gitlab-org/gitlab-ce/issues/17238 and here https://gitlab.com/gitlab-org/gitlab-ce/issues/17238
What is the current bug behavior?
The import of that specific PR fails with an error similar to:
{"type":"pull_request","url":"https://api.github.com/repos/company/repository/pulls/123","errors":"Object not found - no match for id (1234567890abcdef...)"
What is the expected correct behavior?
No errors during the import :)
Relevant logs and/or screenshots
Please see attached log in the Zendesk issue: https://gitlab.zendesk.com/agent/tickets/67647
Results of GitLab environment info
System information
System:
Current User: git
Using RVM: no
Ruby Version: 2.3.3p222
Gem Version: 2.6.6
Bundler Version:1.13.7
Rake Version: 10.5.0
Sidekiq Version:4.2.7
GitLab information
Version: 8.16.1-ee
Revision: 060f824
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: PostgreSQL
DB Version: 9.6.1
URL: https://git.company.com
HTTP Clone URL: https://git.company.com/some-group/some-project.git
SSH Clone URL: git@git.company.com:some-group/some-project.git
Elasticsearch: no
Geo: no
Using LDAP: yes
Using Omniauth: yes
Omniauth Providers: github
GitLab Shell
Version: 4.1.1
Repository storage paths:
- default: /apps/gitlab/git-data/repositories
Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks/
Git: /opt/gitlab/embedded/bin/git
Possible fixes
When the branch exists, check if the sha
is part of the branch we found, otherwise fallback to create a new branch with a pattern we already use to import removed branches.
cc @dbalexandre @DouweM @xiaogang_gitlab @balameb