mysociety / alaveteli

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

[ERROR] statistics#index (Math::DomainError) "Numerical argument is out of domain - \"sqrt\"" #4433

Open gavinrozzi opened 6 years ago

gavinrozzi commented 6 years ago

The public authority statistics page is broken for us and we have begun receiving this error as of Wednesday:

A Math::DomainError occurred in statistics#index:

 Numerical argument is out of domain - "sqrt"
 lib/confidence_intervals.rb:28:in `sqrt'

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

 * URL        : https://opramachine.com/statistics
 * HTTP Method: GET
 * IP address : [FILTERED]
 * Parameters : {"controller"=>"statistics", "action"=>"index"}
 * Timestamp  : 2017-12-20 21:55:36 -0500
 * Server : opramachine.com
 * Rails root : [FILTERED]/opramachine.com/alaveteli
 * Process: 23591

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

 lib/confidence_intervals.rb:28:in `sqrt'
 lib/confidence_intervals.rb:28:in `ci_bounds'
 app/models/public_body.rb:722:in `block in get_request_percentages'
 app/models/public_body.rb:721:in `each'
 app/models/public_body.rb:721:in `each_with_index'
 app/models/public_body.rb:721:in `each'
 app/models/public_body.rb:721:in `map'
 app/models/public_body.rb:721:in `get_request_percentages'
 app/models/statistics.rb:49:in `block (2 levels) in public_bodies'
 app/models/statistics.rb:43:in `each'
 app/models/statistics.rb:43:in `block in public_bodies'
 app/models/statistics.rb:42:in `each'
 app/models/statistics.rb:42:in `public_bodies'
 app/controllers/statistics_controller.rb:7:in `index'
 app/controllers/application_controller.rb:120:in `record_memory'
 lib/strip_empty_sessions.rb:13:in `call'
lizconlan commented 6 years ago

this might be as "simple" a fix as requiring 'mathn' http://ruby-doc.org/stdlib-2.1.5/libdoc/mathn/rdoc/Math.html (this instance is running 2.1.5 but that same note appears in the docs for multiple versions so I don't think this is factor)

(although my lazy reading of this implies we're asking for the square root of a negative number so it might be worth having a dig into what's happening here)

gavinrozzi commented 6 years ago

Just checked the statistics page and strangely enough this error is no longer occurring on https://opramachine.com/statistics#public_bodies No changes have been made to the site since the creation of this issue.

garethrees commented 6 years ago

This also happened on Belgium recently https://groups.google.com/a/mysociety.org/forum/#!topic/cron-alaveteli/IMrvIpFUbd8