# Jobs::HandledExceptionWrapper: Wrapped I18n::InvalidLocale for Jobs::UserEmail

**URL:** https://meta.discourse.org/t/jobs-handledexceptionwrapper-wrapped-i18n-invalidlocale-for-jobs-useremail/40574
**Category:** Bug
**Created:** [2016年三月4日 17:18 UTC](https://meta.discourse.org/t/jobs-handledexceptionwrapper-wrapped-i18n-invalidlocale-for-jobs-useremail/40574 "2016-03-04T17:18:58Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [2016年三月4日 17:18 UTC](https://meta.discourse.org/t/jobs-handledexceptionwrapper-wrapped-i18n-invalidlocale-for-jobs-useremail/40574/1 "2016-03-04T17:18:58Z")

</div>

Continuing the discussion from [Failling jobs in Sidekiq : Jobs::UserEmail](https://meta.discourse.org/t/failling-jobs-in-sidekiq-jobs-useremail/35779):

(I’m not convinced this is linked to the above, but the symptom was similar.)

After testing a group message to a group, I suddely got 2 of these retries alerted in Sidekiq with the error message `Jobs::HandledExceptionWrapper: Wrapped I18n::InvalidLocale: "" is not a valid locale` for the `Jobs::UserEmail` job.

Fortunately it’s not breaking anything critical, but worried it might be a problem if someone needs to send a group message. Any ideas?

 ![](https://global.discourse-cdn.com/meta/original/3X/a/0/a06b41e598b5a942c55496bcd725fd72a2a89bdc.png)

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [2016年三月4日 19:28 UTC](https://meta.discourse.org/t/jobs-handledexceptionwrapper-wrapped-i18n-invalidlocale-for-jobs-useremail/40574/2 "2016-03-04T19:28:07Z")

</div>

Assuming you are right up to date, it’s probably related to this:  
[https://github.com/discourse/discourse/pull/4004](https://github.com/discourse/discourse/pull/4004)

This method should be changed to validate the locale against I18n.available\_locales.

```rb
  def user_locale(user)
    user.respond_to?(:locale) ? user.locale : nil
  end

```

---

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [2016年三月4日 19:45 UTC](https://meta.discourse.org/t/jobs-handledexceptionwrapper-wrapped-i18n-invalidlocale-for-jobs-useremail/40574/3 "2016-03-04T19:45:25Z")

</div>

Yeah I’m definitely up to the hour on tests-passed.

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [2016年三月4日 21:00 UTC](https://meta.discourse.org/t/jobs-handledexceptionwrapper-wrapped-i18n-invalidlocale-for-jobs-useremail/40574/4 "2016-03-04T21:00:07Z")

</div>

Can you check what `locale` returns for those users?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2016年三月4日 21:06 UTC](https://meta.discourse.org/t/jobs-handledexceptionwrapper-wrapped-i18n-invalidlocale-for-jobs-useremail/40574/5 "2016-03-04T21:06:07Z")

</div>

Should probably be

user.locale.present?, it is always going to respond

---

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [2016年三月4日 22:20 UTC](https://meta.discourse.org/t/jobs-handledexceptionwrapper-wrapped-i18n-invalidlocale-for-jobs-useremail/40574/6 "2016-03-04T22:20:30Z")

</div>

> [@simon](#):
>
> Can you check what locale returns for those users?

If you can send me exactly what to run, I can try to get this for you; but as a non-dev I’m not sure what you need. The username blurred out was my own, if that helps. 🙂

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [2016年三月4日 22:25 UTC](https://meta.discourse.org/t/jobs-handledexceptionwrapper-wrapped-i18n-invalidlocale-for-jobs-useremail/40574/7 "2016-03-04T22:25:00Z")

</div>

Thanks, I think it’s sorted out.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2016年三月6日 23:46 UTC](https://meta.discourse.org/t/jobs-handledexceptionwrapper-wrapped-i18n-invalidlocale-for-jobs-useremail/40574/8 "2016-03-06T23:46:59Z")

</div>

This topic was automatically closed after 2 days. New replies are no longer allowed.
