codeforcroatia / imamopravoznati

Provide a Freedom of Information request system for your jurisdiction
http://alaveteli.org
Other
3 stars 1 forks source link

Problem when editing public body #75

Closed schlos closed 4 years ago

schlos commented 5 years ago

Actual behavior

Error 500

[ERROR] [imamopravoznati.org] admin_public_body#show (RuntimeError) "internal error, last_event_forming_initial_request ...

A RuntimeError occurred in admin_public_body#show:

  internal error, last_event_forming_initial_request gets nil for request 6248 outgoing messages count 1 all events: --- []

  app/models/info_request.rb:780:in `last_event_forming_initial_request'

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

  * URL        : http://imamopravoznati.org/admin/bodies/12941
  * HTTP Method: GET
  * IP address :  
  * Parameters : {"controller"=>"admin_public_body", "action"=>"show", "id"=>"12941"}
  * Timestamp  : 2019-09-10 21:34:32 +0200
  * Server : imamopravoznati
  * Rails root : /var/www/imamopravoznati.org/alaveteli
  * Process: 19790

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

  app/models/info_request.rb:780:in `last_event_forming_initial_request'
  app/models/info_request.rb:847:in `calculate_date_initial_request_last_sent_at'
  app/models/info_request.rb:841:in `date_initial_request_last_sent_at'
  app/models/concerns/admin_column.rb:15:in `block in for_admin_column'
  app/models/concerns/admin_column.rb:14:in `each'
  app/models/concerns/admin_column.rb:14:in `for_admin_column'
  app/views/admin_request/_some_requests.html.erb:17:in `block in _app_views_admin_request__some_requests_html_erb__2216653242027161637_82901220'
  app/views/admin_request/_some_requests.html.erb:2:in `_app_views_admin_request__some_requests_html_erb__2216653242027161637_82901220'
  app/views/admin_public_body/show.html.erb:97:in `_app_views_admin_public_body_show_html_erb___3932512601620188209_82426080'
  app/controllers/admin_public_body_controller.rb:29:in `block in show'
  lib/alaveteli_localization.rb:43:in `with_locale'
  app/controllers/admin_public_body_controller.rb:20:in `show'
  app/controllers/application_controller.rb:120:in `record_memory'
  lib/strip_empty_sessions.rb:13:in `call'

Steps to reproduce

  1. Go to http://imamopravoznati.org/admin/bodies/12941

Expected behavior

Should work

schlos commented 5 years ago

Reproducible also with http://imamopravoznati.org/admin/bodies/32386

schlos commented 5 years ago

Reproducible also with http://imamopravoznati.org/admin/bodies/28575

schlos commented 5 years ago

http://imamopravoznati.org/admin/bodies/28648

schlos commented 5 years ago

http://imamopravoznati.org/admin/bodies/28649

schlos commented 5 years ago

http://imamopravoznati.org/admin/bodies/28657

schlos commented 5 years ago

http://imamopravoznati.org/admin/bodies/28695

schlos commented 5 years ago

http://imamopravoznati.org/admin/bodies/29109

schlos commented 5 years ago

http://imamopravoznati.org/admin/bodies/28710

schlos commented 5 years ago

http://imamopravoznati.org/admin/bodies/29008

schlos commented 5 years ago

http://imamopravoznati.org/admin/bodies/29043

schlos commented 4 years ago

http://imamopravoznati.org/admin/bodies/28989

schlos commented 4 years ago

http://imamopravoznati.org/admin/bodies/29123

garethrees commented 4 years ago

Sounds like there are requests made to those authorities that have failed to send. Have a look at https://github.com/mysociety/alaveteli/wiki/Resending-Failed-Outgoing-Messages

schlos commented 4 years ago

To verify if message was stuck in sending status:

alaveteli@imamopravoznati:~/alaveteli$ bundle exec rails console Loading production environment (Rails 4.2.9) irb(main):001:0> InfoRequest.find(6148).outgoing_messages.first.status => "ready"

List all failed sends:

irb(main):002:0> OutgoingMessage.where(:status => 'ready') => #<ActiveRecord::Relation [

<OutgoingMessage id: 1, info_request_id: 1, body: "This is the holding pen request. It shows response...", status: "ready", message_type: "initial_request", created_at: "2015-02-21 11:12:31", updated_at: "2015-02-21 11:12:31", last_sent_at: "2015-02-21 11:12:31", incoming_message_followup_id: nil, what_doing: "normal_sort", prominence: "normal", prominence_reason: nil>,

<OutgoingMessage id: 3166, info_request_id: 1926, body: "Za: Općina Postira\r\n\r\nTemeljem Zakona o pravu na p...", status: "ready", message_type: "initial_request", created_at: "2016-08-11 11:00:16", updated_at: "2016-08-11 11:00:16", last_sent_at: nil, incoming_message_followup_id: nil, what_doing: "normal_sort", prominence: "normal", prominence_reason: nil>,

<OutgoingMessage id: 4486, info_request_id: 3114, body: "Za: Zagrebački holding\r\n\r\nTemeljem Zakona o pravu ...", status: "ready", message_type: "initial_request", created_at: "2017-01-22 23:19:40", updated_at: "2017-01-22 23:19:40", last_sent_at: nil, incoming_message_followup_id: nil, what_doing: "normal_sort", prominence: "normal", prominence_reason: nil>,

<OutgoingMessage id: 8672, info_request_id: 6444, body: "Za: Ured državne uprave u Splitsko-dalmatinskoj žu...", status: "ready", message_type: "initial_request", created_at: "2018-03-21 21:36:33", updated_at: "2018-03-21 21:36:33", last_sent_at: nil, incoming_message_followup_id: nil, what_doing: "normal_sort", prominence: "normal", prominence_reason: nil>,

<OutgoingMessage id: 8673, info_request_id: 6445, body: "Za: Ured državne uprave u Splitsko-dalmatinskoj žu...", status: "ready", message_type: "initial_request", created_at: "2018-03-21 21:39:34", updated_at: "2018-03-21 21:39:34", last_sent_at: nil, incoming_message_followup_id: nil, what_doing: "normal_sort", prominence: "normal", prominence_reason: nil>,

<OutgoingMessage id: 8674, info_request_id: 6446, body: "Za: Ured državne uprave u Splitsko-dalmatinskoj žu...", status: "ready", message_type: "initial_request", created_at: "2018-03-21 22:31:43", updated_at: "2018-03-21 22:31:43", last_sent_at: nil, incoming_message_followup_id: nil, what_doing: "normal_sort", prominence: "normal", prominence_reason: nil>,

<OutgoingMessage id: 8675, info_request_id: 6447, body: "Za: Ured državne uprave u Splitsko-dalmatinskoj žu...", status: "ready", message_type: "initial_request", created_at: "2018-03-21 22:51:56", updated_at: "2018-03-21 22:51:56", last_sent_at: nil, incoming_message_followup_id: nil, what_doing: "normal_sort", prominence: "normal", prominence_reason: nil>,

<OutgoingMessage id: 8642, info_request_id: 6423, body: "Za: Sveučilište u Zagrebu, Prirodoslovno-matematič...", status: "ready", message_type: "initial_request", created_at: "2018-03-07 10:09:10", updated_at: "2018-03-07 10:09:10", last_sent_at: nil, incoming_message_followup_id: nil, what_doing: "normal_sort", prominence: "normal", prominence_reason: nil>,

<OutgoingMessage id: 8646, info_request_id: 6426, body: "Za: Pučki pravobranitelj, Zagreb\r\n\r\nMolim da mi od...", status: "ready", message_type: "initial_request", created_at: "2018-03-08 10:57:26", updated_at: "2018-03-08 10:57:26", last_sent_at: nil, incoming_message_followup_id: nil, what_doing: "normal_sort", prominence: "normal", prominence_reason: nil>,

<OutgoingMessage id: 5105, info_request_id: 3690, body: "Za: Dječji vrtić Bambi, Zadar\r\n\r\nPoštovani,\r\ntemel...", status: "ready", message_type: "initial_request", created_at: "2017-03-26 12:01:57", updated_at: "2017-03-26 12:01:57", last_sent_at: nil, incoming_message_followup_id: nil, what_doing: "normal_sort", prominence: "normal", prominence_reason: nil>,

...]>

schlos commented 4 years ago

Fixed requests id:

schlos commented 4 years ago

All done, final check:

irb(main):949:0> OutgoingMessage.where(:status => 'ready') => #<ActiveRecord::Relation [#<OutgoingMessage id: 1, info_request_id: 1, body: "This is the holding pen request. It shows response...", status: "ready", message_type: "initial_request", created_at: "2015-02-21 11:12:31", updated_at: "2015-02-21 11:12:31", last_sent_at: "2015-02-21 11:12:31", incoming_message_followup_id: nil, what_doing: "normal_sort", prominence: "normal", prominence_reason: nil>]> irb(main):950:0>

only Holding Pen 👍