Import from BitBucket Server fails with if cloning over HTTPS is disabled
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Summary
When trying to import a project from a BitBucket Server that has HTTPS-access disabled the import fails but no error message is provided.
Steps to reproduce
- Turn off HTTPS access in BitBucket Server
- Try to import a project from BitBucket Server
What is the current bug behavior?
The import fails with a generic error message in the UI
What is the expected correct behavior?
Best case, the project is imported over SSH. But at the least the UI should tell the user the reason the import failed.
Relevant logs and/or screenshots
_gitlab-rails/production.log
Started POST "/import/bitbucket_server.json" for 10.217.55.1 at 2023-01-31 08:11:45 +0000
Processing by Import::BitbucketServerController#create as JSON
Parameters: {"repo_id"=>"XXX/YYY", "ci_cd_only"=>false, "new_name"=>"ZZZ", "target_namespace"=>"raniz", "bitbucket_server"=>{"repo_id"=>"XXX/YYY", "ci_cd_only"=>false, "new_name"=>"ZZZ", "target_namespace"=>"raniz"}}
Completed 500 Internal Server Error in 734ms (ActiveRecord: 1.7ms | Elasticsearch: 0.0ms | Allocations: 10331)
NoMethodError (undefined method `fetch' for nil:NilClass):
lib/bitbucket_server/representation/repo.rb:26:in `clone_url'
lib/gitlab/bitbucket_server_import/project_creator.rb:28:in `execute'
app/services/import/bitbucket_server_service.rb:46:in `create_project'
app/services/import/bitbucket_server_service.rb:20:in `execute'
app/controllers/import/bitbucket_server_controller.rb:38:in `create'
ee/lib/gitlab/ip_address_state.rb:10:in `with'
ee/app/controllers/ee/application_controller.rb:46:in `set_current_ip_address'
lib/gitlab/auth/current_user_mode.rb:72:in `with_current_admin'
app/controllers/application_controller.rb:537:in `set_current_admin'
lib/gitlab/session.rb:11:in `with_session'
app/controllers/application_controller.rb:525:in `set_session_storage'
lib/gitlab/i18n.rb:107:in `with_locale'
lib/gitlab/i18n.rb:113:in `with_user_locale'
app/controllers/application_controller.rb:513:in `set_locale'
app/controllers/application_controller.rb:507:in `set_current_context'
lib/gitlab/metrics/elasticsearch_rack_middleware.rb:16:in `call'
lib/gitlab/middleware/memory_report.rb:13:in `call'
lib/gitlab/middleware/speedscope.rb:13:in `call'
lib/gitlab/database/load_balancing/rack_middleware.rb:23: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/web_transaction.rb:46:in `run'
lib/gitlab/metrics/rack_middleware.rb:16: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/query_analyzer.rb:11:in `block in call'
lib/gitlab/database/query_analyzer.rb:37:in `within'
lib/gitlab/middleware/query_analyzer.rb:11:in `call'
lib/gitlab/middleware/multipart.rb:173: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'
lib/gitlab/middleware/request_context.rb:21:in `call'
lib/gitlab/middleware/webhook_recursion_detection.rb:15:in `call'
config/initializers/fix_local_cache_middleware.rb:11:in `call'
lib/gitlab/middleware/compressed_json.rb:37:in `call'
lib/gitlab/middleware/rack_multipart_tempfile_factory.rb:19:in `call'
lib/gitlab/middleware/sidekiq_web_static.rb:20:in `call'
lib/gitlab/metrics/requests_rack_middleware.rb:77:in `call'
lib/gitlab/middleware/release_env.rb:13:in `call'
Results of GitLab environment info
Expand for output related to GitLab environment info
System information
System: Debian 11
Proxy: https_proxy: http://squid.lxd:3128
http_proxy: http://squid.lxd:3128
no_proxy: .local,.lxd
Current User: git
Using RVM: no
Ruby Version: 2.7.7p221
Gem Version: 3.1.6
Bundler Version:2.3.15
Rake Version: 13.0.6
Redis Version: 6.2.8
Sidekiq Version:6.5.7
Go Version: unknown
GitLab information
Version: 15.8.0-ee
Revision: 1d89c23c9f9
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: PostgreSQL
DB Version: 13.8
URL: https://gitlab.lxd
HTTP Clone URL: https://gitlab.lxd/some-group/some-project.git
SSH Clone URL: git@gitlab.lxd:some-group/some-project.git
Elasticsearch: no
Geo: no
Using LDAP: no
Using Omniauth: yes
Omniauth Providers: saml
GitLab Shell
Version: 14.15.0
Repository storages:
- default: unix:/var/opt/gitlab/gitaly/gitaly.socket
GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell
Results of GitLab application Check
Expand for output related to the GitLab application check
Checking GitLab subtasks ...Checking GitLab Shell ...
GitLab Shell: ... GitLab Shell version >= 14.15.0 ? ... OK (14.15.0) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Internal API available: OK Redis available via internal API: OK gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Gitaly ...
Gitaly: ... default ... OK
Checking Gitaly ... Finished
Checking Sidekiq ...
Sidekiq: ... Running? ... yes Number of Sidekiq processes (cluster/worker) ... 1/1
Checking Sidekiq ... Finished
Checking Incoming Email ...
Incoming Email: ... Reply by email is disabled in config/gitlab.yml
Checking Incoming Email ... Finished
Checking LDAP ...
LDAP: ... LDAP is disabled in config/gitlab.yml
Checking LDAP ... Finished
Checking GitLab App ...
Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Cable config exists? ... yes Resque config exists? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... skipped (no tmp uploads folder yet) Systemd unit files or init script exist? ... skipped (omnibus-gitlab has neither init script nor systemd units) Systemd unit files or init script up-to-date? ... skipped (omnibus-gitlab has neither init script nor systemd units) Projects have namespace: ... 2/1 ... yes 4/2 ... yes 9/3 ... yes 8/4 ... yes 20/9 ... yes 24/10 ... yes 24/11 ... yes 4/12 ... yes Redis version >= 6.0.0? ... yes Ruby version >= 2.7.2 ? ... yes (2.7.7) Git user has default SSH configuration? ... yes Active users: ... 3 Is authorized keys file accessible? ... yes GitLab configured to store new projects in hashed storage? ... yes All projects are in hashed storage? ... yes Elasticsearch version 7.x-8.x or OpenSearch version 1.x ... skipped (Advanced Search is disabled) All migrations must be finished before doing a major upgrade ... skipped (Advanced Search is disabled)
Checking GitLab App ... Finished
Checking GitLab subtasks ... Finished
Possible fixes
Relevant line is here, it assumes that it will find a clone-url for https and then calls fetch on that. Since find returns nil an exception is thrown instead.