NoMethodError - Saving Jira integration with invalid credentials
Summary
After the work to store the Jira server type in jira_tracking_data
table !37003 (merged), we get a 500 error when saving the Jira integration with invalid credentials.
Steps to reproduce
- Go to Admin -> Settings -> Integrations http://localhost:3000/admin/application_settings/integrations
- Click on the Jira integration http://localhost:3000/admin/application_settings/integrations/jira/edit
- Complete the settings with invalid information: web URL, username, password
- Click Save changes
💣
Relevant logs and/or screenshots
↳ app/controllers/concerns/integrations_actions.rb:18:in `update'
Completed 500 Internal Server Error in 481ms (ActiveRecord: 6.6ms | Elasticsearch: 0.0ms | Allocations: 53537)
NoMethodError - undefined method `id' for nil:NilClass:
app/models/concerns/project_services_loggable.rb:19:in `build_message'
app/models/concerns/project_services_loggable.rb:11:in `log_error'
app/models/project_services/jira_service.rb:424:in `rescue in jira_request'
app/models/project_services/jira_service.rb:420:in `jira_request'
lib/gitlab/metrics/instrumentation.rb:160:in `block in jira_request'
lib/gitlab/metrics/method_call.rb:27:in `measure'
lib/gitlab/metrics/instrumentation.rb:160:in `jira_request'
app/models/project_services/jira_service.rb:238:in `block in server_info'
lib/gitlab/utils/strong_memoize.rb:30:in `strong_memoize'
app/models/project_services/jira_service.rb:237:in `server_info'
app/models/project_services/jira_service.rb:447:in `update_deployment_type'
config/initializers/forbid_sidekiq_in_transactions.rb:50:in `block in committed!'
config/initializers/forbid_sidekiq_in_transactions.rb:8:in `skipping_transaction_check'
config/initializers/forbid_sidekiq_in_transactions.rb:50:in `committed!'
app/controllers/concerns/integrations_actions.rb:18:in `update'
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:491:in `set_current_admin'
lib/gitlab/session.rb:11:in `with_session'
app/controllers/application_controller.rb:482: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:476:in `set_locale'
lib/gitlab/error_tracking.rb:50:in `with_context'
app/controllers/application_controller.rb:541:in `sentry_context'
app/controllers/application_controller.rb:469:in `block in set_current_context'
lib/gitlab/application_context.rb:52:in `block in use'
lib/gitlab/application_context.rb:52:in `use'
lib/gitlab/application_context.rb:20:in `with_context'
app/controllers/application_controller.rb:462: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:61:in `run'
lib/gitlab/metrics/rack_middleware.rb:16:in `call'
lib/gitlab/request_profiler/middleware.rb:17:in `call'
lib/gitlab/query_limiting/middleware.rb:17:in `block in call'
lib/gitlab/query_limiting/transaction.rb:39:in `run'
lib/gitlab/query_limiting/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:13:in `call'
lib/gitlab/middleware/multipart.rb:142:in `call'
lib/gitlab/middleware/read_only/controller.rb:51:in `call'
lib/gitlab/middleware/read_only.rb:18:in `call'
lib/gitlab/middleware/same_site_cookies.rb:27: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:23:in `call'
config/initializers/fix_local_cache_middleware.rb:9:in `call'
lib/gitlab/middleware/static.rb:11:in `call'
lib/gitlab/webpack/dev_server_middleware.rb:27:in `perform_request'
lib/gitlab/metrics/requests_rack_middleware.rb:60:in `call'
lib/gitlab/middleware/release_env.rb:12:in `call'
Possible fixes
We should not test instance-level integrations, see #213138: https://gitlab.com/gitlab-org/gitlab/-/blob/a875925c/app/models/service.rb#L370-374
after_commit :update_deployment_type, on: [:create, :update], if: :update_deployment_type?
def server_info
strong_memoize(:server_info) do
client_url.present? ? jira_request { client.ServerInfo.all.attrs } : nil
end
end