mysociety / alaveteli

Provide a Freedom of Information request system for your jurisdiction
https://alaveteli.org
Other
389 stars 196 forks source link

Integer `body` URL slugs redirect to seemingly random body ("All roads lead to Flint") #7733

Open confirmordeny opened 1 year ago

confirmordeny commented 1 year ago

https://www.whatdotheyknow.com/body/1 redirects to Flint Town Council, Flintshire as does https://www.whatdotheyknow.com/body/5000 and seemingly every other positive whole number.

gbp commented 1 year ago

Redirection chain from /body/1 -> /body/body -> /body/flint_town_council_flintshire

The first redirect is a result of this check: https://github.com/mysociety/alaveteli/blob/7bbf6e5e5e6f5c412a07c7af641068b898d56431/app/controllers/public_body_controller.rb#L24-L27

As MySociety::Format.simplify_url_part('1', 'body') #=> 'body' as this function doesn't allowing url_name starting with a integer.

The second redirect is because Flint, and 220+ other authorities, all have empty PublicBody::Translation records for the Welsh (cy) locale. When they were created because there are no name in these translations when we generate the url_name it is set to body (same if using the CSV import). The second redirect only happens when viewing the English locale. Going to /cy/body/body does not cause the redirect.

WilliamWDTK commented 3 months ago

For what it's worth (probably nothing), Flint Town Council has been replaced by Birchanger Parish Council (in this error, not in terms of responsibility!).