votingworks / arlo

GNU Affero General Public License v3.0
141 stars 25 forks source link

500 Error with certain vote totals when posting to /manifest endpoint #53

Open MorganLove opened 5 years ago

MorganLove commented 5 years ago

Environments: Tested on current master (and on the branch for PR support multiple contests and candidates)

ERROR in app: Exception on /jurisdiction/jurisdiction-1/manifest [POST]
Traceback (most recent call last):
  File "/Users/morgan/.local/share/virtualenvs/arlo-cgZpGxiy/lib/python3.7/site-packages/flask/app.py", line 2311, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/morgan/.local/share/virtualenvs/arlo-cgZpGxiy/lib/python3.7/site-packages/flask/app.py", line 1834, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/morgan/.local/share/virtualenvs/arlo-cgZpGxiy/lib/python3.7/site-packages/flask/app.py", line 1737, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/morgan/.local/share/virtualenvs/arlo-cgZpGxiy/lib/python3.7/site-packages/flask/_compat.py", line 36, in reraise
    raise value
  File "/Users/morgan/.local/share/virtualenvs/arlo-cgZpGxiy/lib/python3.7/site-packages/flask/app.py", line 1832, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/morgan/.local/share/virtualenvs/arlo-cgZpGxiy/lib/python3.7/site-packages/flask/app.py", line 1818, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/morgan/Desktop/votingworks/arlo/app.py", line 327, in jurisdiction_manifest
    setup_next_round(election)
  File "/Users/morgan/Desktop/votingworks/arlo/app.py", line 81, in setup_next_round
    sample_sizes = sampler.get_sample_sizes(sample_results(election))
  File "/Users/morgan/Desktop/votingworks/arlo/sampler.py", line 198, in get_sample_sizes
    asns = self.get_asns()
  File "/Users/morgan/Desktop/votingworks/arlo/sampler.py", line 139, in get_asns
    asns[contest] = math.ceil((math.log(1/self.risk_limit) + (z_w / 2)) / ((p_w * z_w) + (p_r * z_l)))
ZeroDivisionError: float division by zero
127.0.0.1 - - [24/Jul/2019 11:07:35] "POST /jurisdiction/jurisdiction-1/manifest HTTP/1.1" 500 -
127.0.0.1 - - [24/Jul/2019 11:13:51] "GET /audit/status HTTP/1.1" 200 -

Passing Scenarios

  1. 1 Contest 2 Choices a. Type 1 vote for a b. Type 2 votes for B c. Type 100 votes for total ballots d. Submit Audit settings and upload ballot manifest Result: Able to submit form

  2. 1 Contest 3 Choices a. Type 1 vote for a b. Type 2 votes for B c. Type 3 votes for c d. Type 100 votes for total ballots e. Submit Audit settings and upload ballot manifest Result: Able to submit form

  3. 2 Contests 2 Choices a. Type 1 vote for a for both contests b. Type 2 votes for B for both contests d. Type 100 votes for total ballots e. Submit Audit settings and upload ballot manifest Result: Able to submit form

  4. 2 Contest 3 Choices a. Type 1 vote for a for both b. Type 2 votes for B for both c. Type 3 votes for c for both d. Type 100 votes for total ballots e. Submit Audit settings and upload ballot manifest Result: Able to submit form

Failing Scenarios

  1. 1 Contest 2 Choices a. Type 19 vote for a b. Type 20 votes for B c. Type 40 votes for total ballots d. Submit Audit settings and upload ballot manifest Result: Error

  2. 1 Contest 3 Choices a. Type 19 vote for a b. Type 20 votes for B c. Type 10 votes for c d. Type 40 votes for total ballots e. Submit Audit settings and upload ballot manifest Result: Error

  3. 2 Contests 2 Choices a. Type 19 vote for a for both contests b. Type 20 votes for B for both contests d. Type 40 votes for total ballots e. Submit Audit settings and upload ballot manifest Result: Error

  4. 2 Contest 3 Choices a. Type 19 vote for a for both b. Type 20 votes for B for both c. Type 10 votes for c for both d. Type 40 votes for total ballots e. Submit Audit settings and upload ballot manifest Result: Error

Ballot Manifest: Ballot Manifest May 2019 Election - WYANDOTTE.csv

benadida commented 5 years ago

ah I think this is just because the numbers don't work out with the total number of ballots cast. It doesn't have to match exactly, but it should also be realistic. @mcchilders maybe you can provide some sample 3-choice numbers for the wyandotte manifest that would be reasonable?

benadida commented 5 years ago

@MorganLove maybe we should define an error condition here. If the data is simply invalid to run an audit, what would you like me to return?

MorganLove commented 5 years ago

Maybe you could return a string to check for, such as "invalid data"? And I could check for this and handle the error message on the UI?

On Mon, Jul 29, 2019 at 7:05 PM Ben Adida notifications@github.com wrote:

@MorganLove https://github.com/MorganLove maybe we should define an error condition here. If the data is simply invalid to run an audit, what would you like me to return?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/votingworks/arlo/issues/53?email_source=notifications&email_token=AB5YSK3WCWUMIBWP3JHBD53QB6OXLA5CNFSM4IGTSVHKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3CQT6A#issuecomment-516229624, or mute the thread https://github.com/notifications/unsubscribe-auth/AB5YSKYNXY6F2HVRREB6ZLDQB6OXLANCNFSM4IGTSVHA .

MorganLove commented 5 years ago

@benadida Thinking from a user's perspective, we want to let them know as soon as possible that the numbers entered won't work for calculating an audit. So ideally what would happen is that the backend checks the numbers submitted to /audit/basic and if they are realistic, save them and return a populated audit.contests array in the next /audit/status, but if they are unrealistic, return a useful message in the POST response from the submission to /audit/basic and don't save the data (and the next /audit/status call would return an empty audit.contests array). That way the frontend can await the response from /audit/basic and display the message like a validation error, letting the user know that the numbers provided won't work for an audit. Then they can update the numbers and try again. Are there different reasons why the numbers might not work for running the audit, and thus different possible return messages? If not, you can return whatever and we can just show a generic message like "The audit cannot be calculated with the numbers provided."

eventualbuddha commented 4 years ago

Is this still relevant?