mysociety / alaveteli

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

[ERROR] request#show (Mail::Field::ParseError) "Mail::PhraseList can not parse |Egress Switch: #5103

Open lizconlan opened 5 years ago

lizconlan commented 5 years ago
A Mail::Field::ParseError occurred in request#show:

  Mail::PhraseList can not parse |Egress Switch: Unprotected|
Reason was: Only able to parse up to Egress Switch:
  lib/mail_handler/backends/mail_backend.rb:337:in `extract_attached_message_headers'

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

  * URL        : https://www.whatdotheyknow.com/request/the_identification_of_nurses_by?nocache=incoming-1308830
  * HTTP Method: GET
  * Parameters : {"nocache"=>"incoming-1308830", "controller"=>"request", "action"=>"show", "url_title"=>"the_identification_of_nurses_by"}
  * Timestamp  : 2019-02-11 18:50:48 +0000
  * Rails root : /REDACTED/alaveteli-2019-01-29T15-20-21

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

  lib/mail_handler/backends/mail_backend.rb:337:in `extract_attached_message_headers'
  lib/mail_handler/backends/mail_backend.rb:361:in `block in get_attachment_attributes'
  lib/mail_handler/backends/mail_backend.rb:357:in `each'
  lib/mail_handler/backends/mail_backend.rb:357:in `get_attachment_attributes'
  app/models/incoming_message.rb:536:in `extract_attachments!'
  app/models/incoming_message.rb:98:in `block in parse_raw_email!'
  app/models/incoming_message.rb:97:in `parse_raw_email!'
  app/models/incoming_message.rb:178:in `mail_from'
  app/models/incoming_message.rb:197:in `safe_mail_from'
  app/models/incoming_message.rb:220:in `specific_from_name?'
  app/views/request/_incoming_correspondence.html.erb:4:in `_app_views_request__incoming_correspondence_html_erb___930164822993135701_69939478609980'
  app/views/request/_correspondence.html.erb:4:in `_app_views_request__correspondence_html_erb___2794228250505375380_69939455615740'
  lib/themes/whatdotheyknow-theme/lib/views/request/show.html.erb:70:in `block in _lib_themes_whatdotheyknow_theme_lib_views_request_show_html_erb__2745173728416523070_69939467628560'
  lib/themes/whatdotheyknow-theme/lib/views/request/show.html.erb:68:in `_lib_themes_whatdotheyknow_theme_lib_views_request_show_html_erb__2745173728416523070_69939467628560'
lizconlan commented 5 years ago

Seems to be something specific to this incoming message rather than general to everything Egress related.

lizconlan commented 5 years ago

Related Xapian error (same incoming_message_id):

FAILED ActsAsXapian.update_index job 61445039 Mail::Field::ParseError model InfoRequestEvent id 4057239.

Mail::Field::ParseError: Mail::PhraseList can not parse |Egress Switch: Unprotected|
Reason was: Only able to parse up to Egress Switch:.

This job will be removed from the queue. Once the underlying problem is fixed, manually re-index the model record.

---------
Backtrace
---------

vendor/bundle/ruby/2.3.0/gems/mail-2.6.6/lib/mail/parsers/phrase_lists_parser.rb:10:in `parse'
vendor/bundle/ruby/2.3.0/gems/mail-2.6.6/lib/mail/elements/phrase_list.rb:9:in `initialize'
vendor/bundle/ruby/2.3.0/gems/mail-2.6.6/lib/mail/fields/keywords_field.rb:24:in `new'
vendor/bundle/ruby/2.3.0/gems/mail-2.6.6/lib/mail/fields/keywords_field.rb:24:in `phrase_list'
vendor/bundle/ruby/2.3.0/gems/mail-2.6.6/lib/mail/fields/keywords_field.rb:28:in `keywords'
vendor/bundle/ruby/2.3.0/gems/mail-2.6.6/lib/mail/fields/keywords_field.rb:32:in `encoded'
vendor/bundle/ruby/2.3.0/gems/mail-2.6.6/lib/mail/field.rb:194:in `method_missing'
vendor/bundle/ruby/2.3.0/gems/mail-2.6.6/lib/mail/header.rb:211:in `block in encoded'
vendor/bundle/ruby/2.3.0/gems/mail-2.6.6/lib/mail/header.rb:210:in `each'
vendor/bundle/ruby/2.3.0/gems/mail-2.6.6/lib/mail/header.rb:210:in `encoded'
vendor/bundle/ruby/2.3.0/gems/mail-2.6.6/lib/mail/message.rb:1819:in `encoded'
vendor/bundle/ruby/2.3.0/gems/mail-2.6.6/lib/mail/message.rb:366:in `=='
lib/mail_handler/backends/mail_backend.rb:337:in `extract_attached_message_headers'
lib/mail_handler/backends/mail_backend.rb:361:in `block in get_attachment_attributes'
lib/mail_handler/backends/mail_backend.rb:357:in `each'
lib/mail_handler/backends/mail_backend.rb:357:in `get_attachment_attributes'
app/models/incoming_message.rb:536:in `extract_attachments!'
app/models/incoming_message.rb:98:in `block in parse_raw_email!'
vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `transaction'
vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.10/lib/active_record/transactions.rb:220:in `transaction'
app/models/incoming_message.rb:97:in `parse_raw_email!'
app/models/incoming_message.rb:523:in `get_attachments_for_display'
app/models/incoming_message.rb:709:in `get_present_file_extensions'
app/models/info_request_event.rb:267:in `filetype'
lib/acts_as_xapian/acts_as_xapian.rb:925:in `single_xapian_value'
lib/acts_as_xapian/acts_as_xapian.rb:918:in `xapian_value'
lib/acts_as_xapian/acts_as_xapian.rb:1018:in `block in xapian_index'
lib/acts_as_xapian/acts_as_xapian.rb:1017:in `each'
lib/acts_as_xapian/acts_as_xapian.rb:1017:in `xapian_index'
lib/acts_as_xapian/acts_as_xapian.rb:754:in `run_job'
lib/acts_as_xapian/acts_as_xapian.rb:725:in `block (2 levels) in update_index'
vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transaction'
vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.10/lib/active_record/transactions.rb:220:in `transaction'
lib/acts_as_xapian/acts_as_xapian.rb:714:in `block in update_index'
lib/acts_as_xapian/acts_as_xapian.rb:711:in `each'
lib/acts_as_xapian/acts_as_xapian.rb:711:in `update_index'
lib/acts_as_xapian/tasks/xapian.rake:12:in `block (2 levels) in <top (required)>'
vendor/bundle/ruby/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:271:in `block in execute'
vendor/bundle/ruby/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:271:in `each'
vendor/bundle/ruby/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:271:in `execute'
vendor/bundle/ruby/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:213:in `block in invoke_with_call_chain'
ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
vendor/bundle/ruby/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:193:in `invoke_with_call_chain'
vendor/bundle/ruby/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:182:in `invoke'
vendor/bundle/ruby/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:160:in `invoke_task'
vendor/bundle/ruby/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `block (2 levels) in top_level'
vendor/bundle/ruby/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `each'
vendor/bundle/ruby/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `block in top_level'
vendor/bundle/ruby/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:125:in `run_with_threads'
vendor/bundle/ruby/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:110:in `top_level'
vendor/bundle/ruby/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:83:in `block in run'
vendor/bundle/ruby/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:186:in `standard_exception_handling'
vendor/bundle/ruby/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:80:in `run'
vendor/bundle/ruby/2.3.0/gems/rake-12.3.1/exe/rake:27:in `<top (required)>'
vendor/bundle/ruby/2.3.0/bin/rake:22:in `load'
vendor/bundle/ruby/2.3.0/bin/rake:22:in `<top (required)>'
ruby/gems/2.3.0/gems/bundler-1.16.6/lib/bundler/cli/exec.rb:74:in `load'
ruby/gems/2.3.0/gems/bundler-1.16.6/lib/bundler/cli/exec.rb:74:in `kernel_load'
ruby/gems/2.3.0/gems/bundler-1.16.6/lib/bundler/cli/exec.rb:28:in `run'
ruby/gems/2.3.0/gems/bundler-1.16.6/lib/bundler/cli.rb:424:in `exec'
ruby/gems/2.3.0/gems/bundler-1.16.6/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
ruby/gems/2.3.0/gems/bundler-1.16.6/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
ruby/gems/2.3.0/gems/bundler-1.16.6/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
ruby/gems/2.3.0/gems/bundler-1.16.6/lib/bundler/cli.rb:27:in `dispatch'
ruby/gems/2.3.0/gems/bundler-bundler/vendor/thor/lib/thor/base.rb:466:in `start'
ruby/gems/2.3.0/gems/bundler-1.16.6/lib/bundler/cli.rb:18:in `start'
ruby/gems/2.3.0/gems/bundler-1.16.6/exe/bundle:30:in `block in <top (required)>'
ruby/gems/2.3.0/gems/bundler-1.16.6/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'
ruby/gems/2.3.0/gems/bundler-1.16.6/exe/bundle:22:in `<top (required)>'
rbenv/versions/2.3.8/bin/bundle:22:in `load'
rbenv/versions/2.3.8/bin/bundle:22:in `<main>'
lizconlan commented 5 years ago

The email appears (to Apple Mail) to contain 2 .eml attachments, one of which itself has an attachment.

(As the intent is to cross link to data that is published elsewhere on a separate thread - from the same user - I've added the contents of the mail body manually and will add an annotation to resolve the problems with this request but spending some time stepping through the code to confirm whether it was nested (embedded?) emails which caused the issue might be useful.)

lizconlan commented 5 years ago

Ah, may not have even got as far as trying to read documents inside emails inside other emails. There's a Keywords header (in one of the attached/embedded emails?) that seems to point to our error message:

screen shot 2019-02-12 at 17 53 31