GitLab breaks when submodule URL contains an extra colon

Summary

When a project has a submodule, and the url in .gitmodules is of the form git@gitlab.example.com:group/project.git:branchname, navigating to the project results in a 500 error.

Steps to reproduce

  1. Create a project
  2. Add a submodule with a GIT+SSH url: git@gitlab.example.com:group/project.git
  3. Add :branchname to the url in .gitmodules
  4. Stage, commit, and push
  5. View the project in GitLab

Example Project

https://gitlab.com/firelizzard/gitlab-ce-issue-66778

What is the current bug behavior?

HTTP 500 error.

What is the expected correct behavior?

It works normally.

Relevant logs and/or screenshots

.gitmodules

[submodule "project"]
	path = project
	url = git@gitlab.example.com:group/project.git:branchname

production.log

Completed 500 Internal Server Error in 211ms (ActiveRecord: 25.6ms | Elasticsearch: 0.0ms)
  
ActionView::Template::Error (No route matches {:action=>"show", :controller=>"projects", :id=>"project.git:branchname", :namespace_id=>"group"}, possible unmatched const
raints: [:id]):
    18: 
    19:     - elsif tree_row_type == :commit
    20:       = tree_icon('archive', tree_row.mode, tree_row.name)
    21:       = submodule_link(tree_row, @ref)
    22: 
    23:   %td.d-none.d-sm-table-cell.tree-commit
    24:   %td.tree-time-ago.text-right
  
app/helpers/submodule_helper.rb:39:in `submodule_links_for_url'
app/helpers/submodule_helper.rb:12:in `submodule_links'
app/helpers/diff_helper.rb:96:in `submodule_link'
app/views/projects/tree/_tree_row.html.haml:21:in `_app_views_projects_tree__tree_row_html_haml___2475229674595218273_70023405222640'
app/helpers/tree_helper.rb:23:in `render_tree'
app/views/projects/tree/_tree_content.html.haml:17:in `_app_views_projects_tree__tree_content_html_haml__2122405916087778112_70023404389860'
app/views/projects/_files.html.haml:29:in `_app_views_projects__files_html_haml__566793728407075703_70023416283300'
app/views/projects/show.html.haml:34:in `_app_views_projects_show_html_haml__1940665348396984560_70023481544840'
app/controllers/application_controller.rb:118:in `render'
app/controllers/application_controller.rb:533:in `block in allow_gitaly_ref_name_caching'
lib/gitlab/gitaly_client.rb:300:in `allow_ref_name_caching'
app/controllers/application_controller.rb:532:in `allow_gitaly_ref_name_caching'
ee/lib/gitlab/ip_address_state.rb:10:in `with'
ee/app/controllers/ee/application_controller.rb:39:in `set_current_ip_address'
lib/gitlab/session.rb:11:in `with_session'
app/controllers/application_controller.rb:450:in `set_session_storage'
lib/gitlab/i18n.rb:55:in `with_locale'
lib/gitlab/i18n.rb:61:in `with_user_locale'
app/controllers/application_controller.rb:444:in `set_locale'
lib/gitlab/middleware/rails_queue_duration.rb:27:in `call'
lib/gitlab/metrics/rack_middleware.rb:17:in `block in call'
lib/gitlab/metrics/transaction.rb:57:in `run'
lib/gitlab/metrics/rack_middleware.rb:17:in `call'
lib/gitlab/middleware/multipart.rb:103:in `call'
lib/gitlab/request_profiler/middleware.rb:17:in `call'
ee/lib/gitlab/jira/middleware.rb:17:in `call'
lib/gitlab/middleware/go.rb:20:in `call'
lib/gitlab/etag_caching/middleware.rb:13:in `call'
lib/gitlab/middleware/correlation_id.rb:16:in `block in call'
lib/gitlab/middleware/correlation_id.rb:15:in `call'
lib/gitlab/middleware/read_only/controller.rb:42:in `call'
lib/gitlab/middleware/read_only.rb:18:in `call'
lib/gitlab/middleware/basic_health_check.rb:25:in `call'
lib/gitlab/request_context.rb:26:in `call'
config/initializers/fix_local_cache_middleware.rb:9:in `call'
lib/gitlab/metrics/requests_rack_middleware.rb:29:in `call'
lib/gitlab/middleware/release_env.rb:12:in `call'

Results of GitLab environment info

Expand for output related to GitLab environment info
System information
System:
Proxy:          no
Current User:   git
Using RVM:      no
Ruby Version:   2.6.3p62
Gem Version:    2.7.9
Bundler Version:1.17.3
Rake Version:   12.3.2
Redis Version:  3.2.12
Git Version:    2.22.0
Sidekiq Version:5.2.7
Go Version:     unknown

GitLab information Version: 12.2.0-ee Revision: 30032e00da9 Directory: REDACTED DB Adapter: PostgreSQL DB Version: 9.6.14 URL: REDACTED HTTP Clone URL: REDACTED SSH Clone URL: REDACTED Elasticsearch: no Geo: yes Geo node: Undefined Using LDAP: yes Using Omniauth: yes Omniauth Providers: saml

GitLab Shell Version: 9.3.0 Repository storage paths: REDACTED GitLab Shell path: REDACTED Git: REDACTED

Possible fixes

https://gitlab.com/gitlab-org/gitlab-ce/blob/12-2-stable/app/helpers/submodule_helper.rb#L39

Edited Aug 29, 2019 by Ethan Reesor
Assignee Loading
Time tracking Loading