Skip to content

Don't define ApplicationSetting defaults in a constant

username-removed-128633 requested to merge fix-load-error into master

CE backport: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8671

This solve the following issue:

gitlab-ee master % be rake db:migrate
WARNING: This version of GitLab depends on gitlab-shell 4.1.1, but you're running 4.0.0. Please update gitlab-shell.
D, [2017-01-20T11:01:06.440895 #5428] DEBUG -- sentry: ** [Raven] Unable to autoload constant EE::ApplicationSetting, expected /Users/tsigo/Code/gitlab-development-kit/gitlab-ee/app/models/ee/application_setting.rb to define it excluded from capture due to environment or should_capture callback
rake aborted!
LoadError: Unable to autoload constant EE::ApplicationSetting, expected /Users/tsigo/Code/gitlab-development-kit/gitlab-ee/app/models/ee/application_setting.rb to define it
/Users/tsigo/Code/gitlab-development-kit/gitlab-ee/app/models/application_setting.rb:4:in `<class:ApplicationSetting>'
/Users/tsigo/Code/gitlab-development-kit/gitlab-ee/app/models/application_setting.rb:1:in `<top (required)>'
/Users/tsigo/Code/gitlab-development-kit/gitlab-ee/lib/gitlab/current_settings.rb:41:in `fake_application_settings'
/Users/tsigo/Code/gitlab-development-kit/gitlab-ee/lib/gitlab/current_settings.rb:12:in `ensure_application_settings!'
/Users/tsigo/Code/gitlab-development-kit/gitlab-ee/lib/gitlab/current_settings.rb:7:in `current_application_settings'
/Users/tsigo/Code/gitlab-development-kit/gitlab-ee/lib/gitlab/metrics.rb:11:in `settings'
/Users/tsigo/Code/gitlab-development-kit/gitlab-ee/lib/gitlab/metrics.rb:23:in `enabled?'
/Users/tsigo/Code/gitlab-development-kit/gitlab-ee/lib/gitlab/metrics.rb:143:in `<module:Metrics>'
/Users/tsigo/Code/gitlab-development-kit/gitlab-ee/lib/gitlab/metrics.rb:2:in `<module:Gitlab>'
/Users/tsigo/Code/gitlab-development-kit/gitlab-ee/lib/gitlab/metrics.rb:1:in `<top (required)>'
/Users/tsigo/Code/gitlab-development-kit/gitlab-ee/config/initializers/metrics.rb:1:in `<top (required)>'
/Users/tsigo/Code/gitlab-development-kit/gitlab-ee/config/environment.rb:5:in `<top (required)>'
.git/safe/../../bin/bundle:3:in `load'
.git/safe/../../bin/bundle:3:in `<main>'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)

It seems that the problem is when the defaults are defined in a constant... Moving them to class methods solve the issue. 🤷

Merge request reports