"Source branch does not exist" when it actually exists
Summary
MR widget displays Source branch does not exist. Please restore it or use a different source branch when the branch actually exists. The same MR displays the diff correctly, and the branch is visible when browsing the repository through the UI.
Steps to reproduce
It's not clear how the issue can be reproduced consistently, but the flow is usually something like this:
-
git switch -c <branch>locally. - Stage some files, and make a commit.
- Push the branch to the GitLab remote.
- Open an MR.
https://gitlab.com/gitlab-org/gitlab/-/issues/439613 (confidential customer issue) has some logs which may be relevant.
Example Project
See the details in this internal ticket: https://gitlab.zendesk.com/agent/tickets/256583
What is the current bug behavior?
Merge Request cannot be merged because it erroneously displays Source branch does not exist. Please restore it or use a different source branch
What is the expected correct behavior?
Merge button should be active and there should be no Source branch does not exist. Please restore it or use a different source branch message.
Summary of findings so far
There doesn't appear to be a single root cause for this issue. The investigation is made particularly difficult due to the variety of GitLab versions (15 through 17), configurations, and repositories in use. More recent reports of the issue are limited to self-managed installations; the problem has not recently manifested on GitLab.com.
Users have had varying success addressing the problem with the following remedies:
- Running the manual housekeeping trigger for the affected repository.
- Clearing the Redis branches cache by executing
Project.find_by_full_path('project_path/project').repository.expire_branches_cachein the Rails console. (Reference: https://gitlab.zendesk.com/agent/tickets/607040) - Removing the
noexecflag on the directory containing Gitaly's executable hooks. (Reference: https://gitlab.zendesk.com/agent/tickets/541714) - Increasing compute resources for Sidekiq and Puma. (Reference: https://gitlab.zendesk.com/agent/tickets/551420)