mysociety / alaveteli

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

[ERROR] admin_outgoing_message#resend (RuntimeError) "invalid email passed to address_from_name_and_email" #6013

Open garethrees opened 3 years ago

garethrees commented 3 years ago
A RuntimeError occurred in admin_outgoing_message#resend:

invalid email passed to address_from_name_and_email
lib/mail_handler/backends/mail_backend.rb:391:in `address_from_name_and_email'

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

* URL : https://www.whatdotheyknow.com/admin/outgoing_messages/1079377/resend
* HTTP Method: POST
* Parameters : {"_method"=>"post", "authenticity_token"=>"REDACTED", "controller"=>"admin_outgoing_message", "action"=>"resend", "id"=>"1079377"}
* Timestamp : 2020-12-09 01:30:55 +0000
* Rails root : /data/vhost/www.whatdotheyknow.com/alaveteli-2020-12-08T10-19-03

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

* session id: [FILTERED]
* data: {"session_id"=>"REDACTED",
"locale"=>"en",
"user_id"=>184915,
"remember_me"=>true,
"post_redirect_token"=>"REDACTED",
"_csrf_token"=>"REDACTED",
"using_admin"=>1,
"admin_name"=>"REDACTED"}

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

lib/mail_handler/backends/mail_backend.rb:391:in `address_from_name_and_email'
app/models/info_request.rb:1262:in `recipient_name_and_email'
app/models/outgoing_message.rb:150:in `to'
app/mailers/outgoing_mailer.rb:25:in `initial_request'
app/controllers/admin_outgoing_message_controller.rb:58:in `resend'
app/controllers/application_controller.rb:113:in `record_memory'
lib/strip_empty_sessions.rb:15:in `call'
garethrees commented 3 years ago

Another of these yesterday. Same stack trace, different URL https://www.whatdotheyknow.com/admin/outgoing_messages/1079413/resend

garethrees commented 3 years ago

I think what's happening here is:

  1. A user has submitted a request to a school and received a bounce
  2. We've updated the schools via CSV and some have had their email addresses removed (intentional)
  3. While the body has had an empty email address, an admin has tried to resend a failed outgoing message

The fix is to find the correct request email and update the body, then resend the message.