citizenlabsgr / elections-api

API for voter registration status and sample ballots in Michigan.
https://michiganelections.io
GNU General Public License v3.0
11 stars 8 forks source link

Registration bug #319

Closed joegillon closed 10 months ago

joegillon commented 1 year ago

Jurisdiction Farmington City. If I enter a voter's correct details by hand at the mvic website, it works. But when I send the same details to your API I get a 500 server error. But this only happens with correct details. Change the birth month to an incorrect one and you get the false registration json message.

I can provide you with a few voters if you like.

joegillon commented 1 year ago

Something I'm seeing in these cases - no map. Maybe your code is assuming there is a map and throwing a 500 when it's not there?

image

jacebrowning commented 1 year ago

Thanks for reporting this!

BugSnag captured this exception:

Traceback (most recent call last):
  File "django/core/handlers/base.py", line 197, in _get_response
                  response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "django/views/decorators/csrf.py", line 65, in _view_wrapper
              return view_func(request, *args, **kwargs)
  File "rest_framework/viewsets.py", line 125, in view
              return self.dispatch(request, *args, **kwargs)
  File "rest_framework/views.py", line 509, in dispatch
              response = self.handle_exception(exc)
  File "rest_framework/views.py", line 469, in handle_exception
              self.raise_uncaught_exception(exc)
  File "rest_framework/views.py", line 480, in raise_uncaught_exception
          raise exc
  File "rest_framework/views.py", line 506, in dispatch
              response = handler(request, *args, **kwargs)
  File "django/utils/decorators.py", line 48, in _wrapper
          return bound_method(*args, **kwargs)
  File "django/utils/decorators.py", line 188, in _view_wrapper
                          result = _process_exception(request, e)
  File "django/utils/decorators.py", line 186, in _view_wrapper
                          response = view_func(request, *args, **kwargs)
  File "elections/views.py", line 31, in list
          registration_status = voter.fetch_registration_status()
  File "elections/models.py", line 302, in fetch_registration_status
              precinct, created = Precinct.objects.get_or_create(
  File "django/db/models/manager.py", line 87, in manager_method
                  return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "django/db/models/query.py", line 946, in get_or_create
              return self.get(**kwargs), False
  File "django/db/models/query.py", line 650, in get
          raise self.model.MultipleObjectsReturned(
elections.models.MultipleObjectsReturned: get() returned more than one Precinct -- it returned 2!

I'll look into into this in the next few days.

joegillon commented 1 year ago

Sure. As I said, I can provide cases. Sent from my iPadOn Nov 17, 2023, at 2:15 PM, Jace Browning @.> wrote: Thanks for reporting this! BugSnag captured this exception: Traceback (most recent call last): File "django/core/handlers/base.py", line 197, in _get_response response = wrapped_callback(request, callback_args, callback_kwargs) File "django/views/decorators/csrf.py", line 65, in _view_wrapper return view_func(request, *args, kwargs) File "rest_framework/viewsets.py", line 125, in view return self.dispatch(request, *args, *kwargs) File "rest_framework/views.py", line 509, in dispatch response = self.handle_exception(exc) File "rest_framework/views.py", line 469, in handle_exception self.raise_uncaught_exception(exc) File "rest_framework/views.py", line 480, in raise_uncaught_exception raise exc File "rest_framework/views.py", line 506, in dispatch response = handler(request, args, kwargs) File "django/utils/decorators.py", line 48, in _wrapper return bound_method(*args, kwargs) File "django/utils/decorators.py", line 188, in _view_wrapper result = _process_exception(request, e) File "django/utils/decorators.py", line 186, in _view_wrapper response = view_func(request, *args, *kwargs) File "elections/views.py", line 31, in list registration_status = voter.fetch_registration_status() File "elections/models.py", line 302, in fetch_registration_status precinct, created = Precinct.objects.get_or_create( File "django/db/models/manager.py", line 87, in manager_method return getattr(self.get_queryset(), name)(args, kwargs) File "django/db/models/query.py", line 946, in get_or_create return self.get(**kwargs), False File "django/db/models/query.py", line 650, in get raise self.model.MultipleObjectsReturned( elections.models.MultipleObjectsReturned: get() returned more than one Precinct -- it returned 2!

I'll look into into this in the next few days.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

jacebrowning commented 1 year ago

The issue seems to be that the "Am I registered?" page on MVIC does not list a Ward for "Farmington City" but this API has scraped sample ballots with "Ward 1", so there are conflicting precinct records. Do you know if "Farmington City" is actually divided into Wards? have to see how widespread the issue is.

joegillon commented 1 year ago

Works for my scrape. Which looks for that data in the hidden inputs rather than what the user sees. Sent from my iPadOn Nov 18, 2023, at 5:28 PM, Jace Browning @.***> wrote: The issue seems to be that the "Am I registered?" page on MVIC does not list a Ward for "Farmington City" but this API has scraped sample ballots with "Ward 1", so there are conflicting precinct records. I have to see how widespread the issue is.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

jacebrowning commented 1 year ago

I deployed a workaround for the conflicting precinct records. Let me know if the API is working for you again.