Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ERROR] request#upload_response (TypeError) "no implicit conversion of nil into String" #5895

Closed
garethrees opened this issue Sep 24, 2020 · 2 comments
Labels
bug Breaks expected functionality f:request-management x:rwanda

Comments

@garethrees
Copy link
Member

A TypeError occurred in request#upload_response:

no implicit conversion of nil into String
app/controllers/request_controller.rb:461:in `escapeHTML'


-------------------------------
Request:
-------------------------------

* URL : https://sobanukirwa.rw/rw/upload/request/iwould_like_to_ask_different_asp
* HTTP Method: GET
* Parameters : {"controller"=>"request", "action"=>"upload_response", "url_title"=>"iwould_like_to_ask_different_asp", "locale"=>"rw"}
* Timestamp : 2020-09-24 02:38:24 +0200
* Rails root : /data/vhost/rwanda.alaveteli.org/alaveteli-2020-09-22T15-07-36

-------------------------------
Session:
-------------------------------

* session id: [FILTERED]
* data: {"session_id"=>"f4eb9f392cc085018650214171a5d4ab", "locale"=>"rw"}

-------------------------------
Backtrace:
-------------------------------

app/controllers/request_controller.rb:461:in `escapeHTML'
app/controllers/request_controller.rb:461:in `block in upload_response'
lib/alaveteli_localization.rb:46:in `with_locale'
app/controllers/request_controller.rb:455:in `upload_response'
app/controllers/application_controller.rb:116:in `record_memory'
lib/strip_empty_sessions.rb:15:in `call'
@garethrees garethrees added bug Breaks expected functionality x:rwanda f:request-management labels Sep 24, 2020
@garethrees
Copy link
Member Author

Hitting the URL without the rw locale results in a redirect to sign in. For some reason that isn't happening here.

@garethrees
Copy link
Member Author

Same problem as #5382. We're calling PublicBody#name where we've found a PublicBody but aren't correctly falling back to the default locale translation.

https://github.com/mysociety/alaveteli/blob/0.38.1.1/app/controllers/request_controller.rb#L461

mysociety-pusher pushed a commit that referenced this issue Sep 24, 2020
When a site has an underscore locale (e.g. "fr_BE") set as the default,
it is not included in the I18n fallbacks for non-default locales.

    I18n.fallbacks
    # => { :fr_BE => [:fr_BE, :"fr-BE", :fr],
    #      :nl_BE => [:nl_BE, :"fr-BE", :fr] }

    AlaveteliLocalization.with_locale(:fr_BE) { Globalize.fallbacks }
    # => [:fr_BE, :"fr-BE", :fr]
    AlaveteliLocalization.with_locale(:nl_BE) { Globalize.fallbacks }
    # => [:nl_BE, :"fr-BE", :fr]

In the example above, this means that a missing model translation when
using the "nl_BE" locale will **not** correctly fall back to the
translation for the default locale ("fr_BE").

This commit ensures that the default locale is always available in the
fallbacks for non-default locales. We try to add it before the
non-underscore version so that the regional translation is preferred,
with the non-regional fallback available as a last-ditch attempt to find
a useful translation.

Globalize model attributes fallbacks specs contributed by @gbp.

Fixes #5382
Fixes #5895
mysociety-pusher pushed a commit that referenced this issue Sep 24, 2020
When a site has an underscore locale (e.g. "fr_BE") set as the default,
it is not included in the I18n fallbacks for non-default locales.

    I18n.fallbacks
    # => { :fr_BE => [:fr_BE, :"fr-BE", :fr],
    #      :nl_BE => [:nl_BE, :"fr-BE", :fr] }

    AlaveteliLocalization.with_locale(:fr_BE) { Globalize.fallbacks }
    # => [:fr_BE, :"fr-BE", :fr]
    AlaveteliLocalization.with_locale(:nl_BE) { Globalize.fallbacks }
    # => [:nl_BE, :"fr-BE", :fr]

In the example above, this means that a missing model translation when
using the "nl_BE" locale will **not** correctly fall back to the
translation for the default locale ("fr_BE").

This commit ensures that the default locale is always available in the
fallbacks for non-default locales. We try to add it before the
non-underscore version so that the regional translation is preferred,
with the non-regional fallback available as a last-ditch attempt to find
a useful translation.

Globalize model attributes fallbacks specs contributed by @gbp.

Fixes #5382
Fixes #5895
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Breaks expected functionality f:request-management x:rwanda
Projects
None yet
Development

No branches or pull requests

1 participant