Switching branches in gitlab-ee causing 500 response

Hi,

I have recently upgraded from gitlab-ee-13.6.1 to gitlab-ee-13.7.2 on a self-managed system and I am now getting the below error/s when switching from the default branch (development) to a different branch on a specific repository.

This only occurs when the default branch is called “development” and is protected.

The “500” error occurs when switching branches on the graph page as well as contributors page as the URL becomes https:///development/digital-channels/mobile-apps/mobile-banking-app-ios/-/refs/switch?utf8=✓&destination=graph&ref=master&path=digital-channels%2Fmobile-apps%2Fmobile-banking-app-ios%2F-%2Fnetwork%2F

The “404” error occurs on the commits page, as the URL then becomes
https:///development/digital-channels/mobile-apps/mobile-banking-app-ios/-/commits/master/digital-channels/mobile-apps/mobile-banking-app-ios/-/commits/
rather than
https:///development/digital-channels/mobile-apps/mobile-banking-app-ios/-/commits/master/

Both instances appear to be appending the URL string rather than replacing it.

From the gitlab-rails production.log for the 500 error:

Started GET "/development/digital-channels/mobile-apps/mobile-banking-app-ios/-/refs/switch?utf8=%E2%9C%93&destination=graph&ref=master&path=digital-channels%2Fmobile-apps%2Fmobile-banking-app-ios%2F-%2Fnetwork%2F" for 10.6.56.167 at 2021-01-13 09:52:37 +1000
Processing by Projects::RefsController#switch as HTML
  Parameters: {"utf8"=>"✓", "destination"=>"graph", "ref"=>"master", "path"=>"digital-channels/mobile-apps/mobile-banking-app-ios/-/network/", "namespace_id"=>"development/digital-channels/mobile-apps", "project_id"=>"mobile-banking-app-ios"}
Completed 500 Internal Server Error in 78ms (ActiveRecord: 7.1ms | Elasticsearch: 0.0ms | Allocations: 16662)
  
ActionController::UrlGenerationError (No route matches {:action=>"show", :controller=>"projects/network", :id=>"master/digital-channels/mobile-apps/mobile-banking-app-ios/-/network/", :namespace_id=>#<Group id:40 @development/digital-channels/mobile-apps>, :project_id=>#<Project id:375 development/digital-channels/mobile-apps/mobile-banking-app-ios>>}, possible unmatched constraints: [:id]):
  
config/application.rb:384:in `block (4 levels) in <class:Application>'
app/controllers/projects/refs_controller.rb:26:in `block (2 levels) in switch'
app/controllers/projects/refs_controller.rb:17:in `switch'
ee/lib/gitlab/ip_address_state.rb:10:in `with'
ee/app/controllers/ee/application_controller.rb:44:in `set_current_ip_address'
app/controllers/application_controller.rb:494:in `set_current_admin'
lib/gitlab/session.rb:11:in `with_session'
app/controllers/application_controller.rb:485:in `set_session_storage'
lib/gitlab/i18n.rb:73:in `with_locale'
lib/gitlab/i18n.rb:79:in `with_user_locale'
app/controllers/application_controller.rb:479:in `set_locale'
lib/gitlab/error_tracking.rb:52:in `with_context'
app/controllers/application_controller.rb:544:in `sentry_context'
app/controllers/application_controller.rb:472:in `block in set_current_context'
lib/gitlab/application_context.rb:54:in `block in use'
lib/gitlab/application_context.rb:54:in `use'
lib/gitlab/application_context.rb:21:in `with_context'
app/controllers/application_controller.rb:464:in `set_current_context'
lib/gitlab/metrics/elasticsearch_rack_middleware.rb:16:in `call'
lib/gitlab/middleware/rails_queue_duration.rb:33:in `call'
lib/gitlab/metrics/rack_middleware.rb:16:in `block in call'
lib/gitlab/metrics/transaction.rb:56:in `run'
lib/gitlab/metrics/rack_middleware.rb:16:in `call'
lib/gitlab/request_profiler/middleware.rb:17:in `call'
lib/gitlab/jira/middleware.rb:19:in `call'
lib/gitlab/middleware/go.rb:20:in `call'
lib/gitlab/etag_caching/middleware.rb:21:in `call'
lib/gitlab/middleware/multipart.rb:234:in `call'
lib/gitlab/middleware/read_only/controller.rb:50:in `call'
lib/gitlab/middleware/read_only.rb:18:in `call'
lib/gitlab/middleware/same_site_cookies.rb:27:in `call'
lib/gitlab/middleware/handle_malformed_strings.rb:21:in `call'
lib/gitlab/middleware/basic_health_check.rb:25:in `call'
lib/gitlab/middleware/handle_ip_spoof_attack_error.rb:25:in `call'

From the gitlab-rails production.log for the 404 error:

Started GET "/development/digital-channels/mobile-apps/mobile-banking-app-ios/-/refs/switch?utf8=%E2%9C%93&destination=commits&ref=master&path=digital-channels%2Fmobile-apps%2Fmobile-banking-app-ios%2F-%2Fcommits%2F" for 10.6.56.167 at 2021-01-13 12:05:14 +1000
Processing by Projects::RefsController#switch as HTML
  Parameters: {"utf8"=>"✓", "destination"=>"commits", "ref"=>"master", "path"=>"digital-channels/mobile-apps/mobile-banking-app-ios/-/commits/", "namespace_id"=>"development/digital-channels/mobile-apps", "project_id"=>"mobile-banking-app-ios"}
Redirected to https://gitlab.hbs.net.au/development/digital-channels/mobile-apps/mobile-banking-app-ios/-/commits/master/digital-channels/mobile-apps/mobile-banking-app-ios/-/commits/
Completed 302 Found in 131ms (ActiveRecord: 21.6ms | Elasticsearch: 0.0ms | Allocations: 14287)
Started GET "/development/digital-channels/mobile-apps/mobile-banking-app-ios/-/commits/master/digital-channels/mobile-apps/mobile-banking-app-ios/-/commits/" for 10.6.56.167 at 2021-01-13 12:05:14 +1000
Processing by Projects::CommitsController#show as HTML
  Parameters: {"namespace_id"=>"development/digital-channels/mobile-apps", "project_id"=>"mobile-banking-app-ios", "id"=>"master/digital-channels/mobile-apps/mobile-banking-app-ios/-/commits"}
Filter chain halted as :set_commits rendered or redirected
Completed 404 Not Found in 157ms (Views: 24.4ms | ActiveRecord: 23.1ms | Elasticsearch: 0.0ms | Allocations: 30921)

I have tested with different default branch names and branch protections, which is why I can specify the branch name and protection above. It seems to work without issue for other default branch names.

Thanks