farend / redmine_message_customize

This is a plugin for Redmine.
GNU General Public License v2.0
29 stars 11 forks source link

"find_or_default" error when reloading with some plugins which use "deface" gem in Redmine 5.1 environment #67

Closed sanak closed 3 months ago

sanak commented 3 months ago

I encountered the following error when reloading with some plugins which use deface gem in Redmine 5.1-stable branch environment.

RuntimeError (There's no setting named plugin_redmine_message_customize):

app/models/setting.rb:361:in `find_or_default'
plugins/redmine_message_customize/app/models/custom_message_setting.rb:6:in `find_or_default'
plugins/redmine_message_customize/config/locales/custom_messages/ar.rb:1:in `load_rb'
plugins/redmine_custom_fields_groups/app/overrides/issues.rb:2:in `new'
plugins/redmine_custom_fields_groups/app/overrides/issues.rb:2:in `<module:Issues>'
plugins/redmine_custom_fields_groups/app/overrides/issues.rb:1:in `<top (required)>'
plugins/redmine_custom_fields_groups/init.rb:29:in `require_relative'
plugins/redmine_custom_fields_groups/init.rb:29:in `<top (required)>'
lib/redmine/plugin_loader.rb:31:in `load'
lib/redmine/plugin_loader.rb:31:in `run_initializer'
lib/redmine/plugin_loader.rb:108:in `each'
lib/redmine/plugin_loader.rb:108:in `block in load'

But, I couldn't find which plugin side causes the error, because deface side seems to require some hacks. (But, sorry. I haven't checked the details about deface side yet... ๐Ÿ™‡๐Ÿ’ฆ) https://github.com/jbbarth/redmine_base_deface/blob/master/init.rb#L13-L39

If someone know what could be the cause, telling us is really helpful... ๐Ÿ™ ๐Ÿ™‡โ€โ™‚๏ธ

Here is my minimum reproducible steps in one of our plugins which use deface gem.

  1. Setup env
    git clone git@github.com:redmine/redmine.git -b 5.1-stable redmine-message-customize
    cd redmine-message-customize
    # Create and adjust config/database.yml (We are using "postgresql" adapter)
    cd plugins
    git clone git@github.com:farend/redmine_message_customize.git
    git clone git@github.com:gtt-project/redmine_custom_fields_groups.git
    cd ../
    bundle install
    bundle exec rake db:create
    bundle exec rake db:migrate
    bundle exec rake db:fixtures:load
    bundle exec rake redmine:plugins:migrate
  2. Launch rails server
    bundle exec rails s -b 0
  3. Open http://localhost:3000 with a browser, then login and move to /projects path.
  4. Modify message customize plugin's ja locale file.
    --- a/config/locales/ja.yml
    +++ b/config/locales/ja.yml
    :
    -  label_default_messages: ใƒ‡ใƒ•ใ‚ฉใƒซใƒˆใฎใƒกใƒƒใ‚ปใƒผใ‚ธใ‚’็ขบ่ชใ™ใ‚‹
    +  label_default_messages: ใƒ‡ใƒ•ใ‚ฉใƒซใƒˆใฎใƒกใƒƒใ‚ปใƒผใ‚ธใ‚’็ขบ่ชใ™ใ‚‹123
  5. Reload the browser, then you will see the description top error message.
sanak commented 3 months ago

From some investigate, the error cause seems to be our plugin side's insufficient Zeitwerk support. Because the following custom_fields_groups plugin's side change, the above error doesn't happen. https://github.com/gtt-project/redmine_custom_fields_groups/pull/38

I close this issue and sorry for bothering. ๐Ÿ™‡โ€โ™‚๏ธ๐Ÿ’ฆ