wevote / WeVoteServer

We Vote's API application server written in Django/Python. Election data pulled from many sources, used by https://github.com/wevote/WebApp and https://github.com/wevote/WeVoteCordova and https://github.com/wevote/Campaigns.
https://api.wevoteusa.org
MIT License
50 stars 451 forks source link

retrieve_voter_guide_possibility crashes when trying to dereference voter_guide_possibility_on_stage #1038

Closed SailingSteve closed 5 years ago

SailingSteve commented 5 years ago

retrieve_voter_guide_possibility crashes when trying to dereference voter_guide_possibility_on_stage when there is no match in the db. The url has never been suggested as a possibility before, in my case http://www.podell.com/wevote/

I avoided the dereference crash as follows at line 2041 in voter_guide/models

        voter_guide_possibility_on_stage_found = True if voter_guide_possibility_on_stage_id > 0 else False
        organization_we_vote_id_results = voter_guide_possibility_on_stage.organization_we_vote_id if \
            voter_guide_possibility_on_stage else None
        voter_guide_possibility_url_results = voter_guide_possibility_on_stage.voter_guide_possibility_url if \
            voter_guide_possibility_on_stage else None
        results = {
            'success':                          success,
            'status':                           status,
            'organization_we_vote_id':          organization_we_vote_id_results,
            'voter_guide_possibility':          voter_guide_possibility_on_stage,
            'voter_guide_possibility_found':    voter_guide_possibility_on_stage_found,
            'voter_guide_possibility_id':       voter_guide_possibility_on_stage_id,
            'voter_guide_possibility_url':      voter_guide_possibility_url_results,
            'error_result':                     error_result,
            'DoesNotExist':                     exception_does_not_exist,
            'MultipleObjectsReturned':          exception_multiple_object_returned,
        }

But I don't have data in my local to test it. Could you test it for me?

DaleMcGrew commented 5 years ago

Hi @SailingSteve, my apologies for the delay -- the crash is fixed, and on the live server. That said I found that some other work is needed on the topic of doing the first full scan of a page. I will email you details.