Improve error message when the gitlab_schema is not added
What does this MR do and why?
If a new database dictionary file is added without the gitlab_schema
field populated, the following error may be raised by the system:
Command failed: rails aborted! (RuntimeError)
NoMethodError: undefined method `to_sym' for nil:NilClass
/Users/dblessing/development/gdk/gitlab/lib/gitlab/database/gitlab_schema.rb:124:in `block in build_dictionary'
/Users/dblessing/development/gdk/gitlab/lib/gitlab/database/gitlab_schema.rb:119:in `each'
/Users/dblessing/development/gdk/gitlab/lib/gitlab/database/gitlab_schema.rb:119:in `each_with_object'
/Users/dblessing/development/gdk/gitlab/lib/gitlab/database/gitlab_schema.rb:119:in `build_dictionary'
/Users/dblessing/development/gdk/gitlab/lib/gitlab/database/gitlab_schema.rb:107:in `tables_to_schema'
/Users/dblessing/development/gdk/gitlab/lib/gitlab/database/gitlab_schema.rb:84:in `views_and_tables_to_schema'
/Users/dblessing/development/gdk/gitlab/lib/gitlab/database/gitlab_schema.rb:39:in `table_schema'
/Users/dblessing/development/gdk/gitlab/app/models/concerns/cross_database_modification.rb:110:in `gitlab_schema'
/Users/dblessing/development/gdk/gitlab/app/models/concerns/cross_database_modification.rb:87:in `block in transaction'
/Users/dblessing/development/gdk/gitlab/lib/gitlab/database.rb:347:in `block in transaction'
/Users/dblessing/development/gdk/gitlab/lib/gitlab/database.rb:346:in `transaction'
/Users/dblessing/development/gdk/gitlab/app/models/concerns/cross_database_modification.rb:83:in `transaction'
/Users/dblessing/development/gdk/gitlab/app/models/application_setting.rb:765:in `create_from_defaults'
/Users/dblessing/development/gdk/gitlab/lib/gitlab/current_settings.rb:71:in `uncached_application_settings'
/Users/dblessing/development/gdk/gitlab/lib/gitlab/current_settings.rb:42:in `ensure_application_settings!'
/Users/dblessing/development/gdk/gitlab/lib/gitlab/current_settings.rb:15:in `block in current_application_settings'
/Users/dblessing/development/gdk/gitlab/lib/gitlab/null_request_store.rb:34:in `fetch'
/Users/dblessing/development/gdk/gitlab/lib/gitlab/safe_request_store.rb:12:in `fetch'
/Users/dblessing/development/gdk/gitlab/lib/gitlab/current_settings.rb:15:in `current_application_settings'
/Users/dblessing/development/gdk/gitlab/lib/banzai/filter/asset_proxy_filter.rb:40:in `initialize_settings'
/Users/dblessing/development/gdk/gitlab/config/initializers/asset_proxy_settings.rb:7:in `block in <main>'
/Users/dblessing/development/gdk/gitlab/config/initializers/asset_proxy_settings.rb:6:in `<main>'
/Users/dblessing/development/gdk/gitlab/config/environment.rb:7:in `<main>'
This happens because the system loads a nil value from the database dictionary file.
Issue: gitlab-org/database-team/team-tasks#330 (closed)
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Diogo Frazão