zulip / zulip-redmine-plugin

Redmine plugin for Zulip notifications on issue tracker changes
Apache License 2.0
12 stars 17 forks source link

I18n::InvalidLocale ("" is not a valid locale) #28

Closed hi-ko closed 4 years ago

hi-ko commented 4 years ago

Only on some tickets/issues we see http 500s on ticket update but I couldn't find thre reason yet:

Started PATCH "/issues/7478" for 1.2.3.4 at 2019-10-30 14:31:03 +0100
Processing by IssuesController#update as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=> [...]
  Current user: test (id=3)
Completed 500 Internal Server Error in 282ms (ActiveRecord: 21.2ms)

I18n::InvalidLocale ("" is not a valid locale):

plugins/redmine_zulip/lib/redmine_zulip/issue_patch.rb:160:in `notify_assigned_to_issue_updated'
app/controllers/issues_controller.rb:552:in `save_issue_with_child_records'
app/controllers/issues_controller.rb:169:in `update'
lib/redmine/sudo_mode.rb:63:in `sudo_mode'

locale is in redmine app config and for all users involved in that specific ticket. I guess the default locale (which should be the redmine's app setting) is not resolved in some cases. I will make some further tests but maybe one could already see the issue with line 160 in issue_patch.rb ...

batistadasilva commented 4 years ago

hi @hi-ko, thanks again for the great feedbacks

could you try with the new released 3.1.1 version?

it seemed that it happened when the user assigned to the ticket had their language set as (auto)

hi-ko commented 4 years ago

hi @felipebatista, what a coincidence - I just openend the ticket with my finding / fix: The issue is with locale = assigned_to.language when a ticket is assigned to a group which by default has language "" (not nil) assigned. I'm not a ruby coder but I endet up with:

assigned_to.language == "" ? locale = Setting.default_language :  locale = assigned_to.language || locale = "en"
batistadasilva commented 4 years ago

this is quite the same I have done on 2097a48

hi-ko commented 4 years ago

hi @felipebatista, ideed your implementation looks quite better and I can confirm that this fixes the issue.

By the way I also realized that I mismatched variable names (s/project_name/project/) in the german translation de.yml - so I will send you a pull request with the fixed version. Thank you for the great support!