When you create a repository mirror with an invalid URI, the "Repository Settings" page for that project breaks
Summary
If you create a mirror repo (Project settings > Repository Settings > Mirroring Repositories) in gitlab, and you enter an invalid URI into the URL field and then save the mirror hit "Mirror repository", this immediately makes the page return a 500 error. You can no longer access this page at all, meaning you cannot revert the setting that caused this issue. This setting is not exposed via the api in CE (only in EE i think, but I am not sure), so the only way to fix would be directly via the DB.
Steps to reproduce
In a project, go to "Project settings > Repository Settings > Mirroring Repositories"
Add a new "push" mirror repo with a bad URI (in my case, it contained a space)
Example Project
I was able to reproduce in gitlab.com - see here:
https://gitlab.com/benmcbenben/test-project/-/settings/repository (happy to give whoever access to this repo if required.
What is the current bug behavior?
Page returns a 500 error.
What is the expected correct behavior?
Not save the bad URI in the first place.
Relevant logs and/or screenshots
This was output in the production.log file:
Processing by Projects::Settings::RepositoryController#show as HTML
Parameters: {"namespace_id"=>"ansible-network", "project_id"=>"domain-name"}
Completed 500 Internal Server Error in 168ms (ActiveRecord: 26.5ms)
ActionView::Template::Error (bad URI(is not URI?): "ssh://10.26.40.19/ansible-network/ domain-name.git"):
52: - @project.remote_mirrors.each_with_index do |mirror, index|
53: - next if mirror.new_record?
54: %tr.qa-mirrored-repository-row.rspec-mirrored-repository-row{ class: ('bg-secondary' if mirror.disabled?) }
55: %td.qa-mirror-repository-url= mirror.safe_url
56: %td= _('Push')
57: %td
58: = mirror.last_update_started_at.present? ? time_ago_with_tooltip(mirror.last_update_started_at) : _('Never')
app/models/remote_mirror.rb:199:in `safe_url'
app/views/projects/mirrors/_mirror_repos.html.haml:55:in `block in _app_views_projects_mirrors__mirror_repos_html_haml___2092687265048723590_70338861862520'
app/views/projects/mirrors/_mirror_repos.html.haml:52:in `each_with_index'
app/views/projects/mirrors/_mirror_repos.html.haml:52:in `_app_views_projects_mirrors__mirror_repos_html_haml___2092687265048723590_70338861862520'
app/views/projects/settings/repository/show.html.haml:7:in `_app_views_projects_settings_repository_show_html_haml___2683724266263580124_70338861246380'
app/controllers/application_controller.rb:118:in `render'
app/controllers/projects/settings/repository_controller.rb:47:in `render_show'
app/controllers/projects/settings/repository_controller.rb:10:in `show'
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/multipart.rb:103:in `call'
lib/gitlab/request_profiler/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:40: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'
lib/gitlab/metrics/requests_rack_middleware.rb:29:in `call'
lib/gitlab/middleware/release_env.rb:12:in `call'
I am unable to provide outputs of the tool outputs, but we are running version 12.2.1