Open theref opened 1 year ago
💎 Sweep Pro: I used GPT-4 to create this ticket. You have unlimited GPT-4 tickets. To retrigger Sweep, edit the issue.
I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.
From looking through the relevant snippets, I decided to make the following modifications:
File Path | Proposed Changes |
---|---|
client_code/services/proof.py |
Modify client_code/services/proof.py with contents: • Modify the prove_eligibility function to catch any exceptions when trying to connect to Sismo. If an exception is caught, redirect to the ballot page using the ballot's UUID. |
client_code/forms/routes/vote/ChooseCandidate/__init__.py |
Modify client_code/forms/routes/vote/ChooseCandidate/init.py with contents: • In the __init__ method of the ChooseCandidate class, add a check to see if the proof is valid. If it is not, redirect to the ballot page using the ballot's UUID. |
I have created a plan for writing the pull request. I am now working my plan and coding the required changes to address this issue. Here is the planned pull request:
Fix redirect error when using invalid Sismo group ID
sweep/fix-redirect-error
Description
This PR fixes the issue where, when a user tries to vote on a ballot with an invalid Sismo group ID, the application throws a LookupError when redirecting back from Sismo. The error message is
'vote/choose/<ID>' does not exist
. This PR modifies the code to handle this error and redirect the user to the correct ballot page.Summary
- Modified the
prove_eligibility
function inclient_code/services/proof.py
to catch any exceptions when connecting to Sismo. If an exception is caught, the user is redirected to the ballot page using the ballot's UUID.- Modified the
ChooseCandidate
class inclient_code/forms/routes/vote/ChooseCandidate/__init__.py
to check if the proof is valid. If it is not, the user is redirected to the ballot page using the ballot's UUID.This PR ensures that users are redirected to the correct ballot page when there is an error with the Sismo proof generation process.
File | Instructions | Progress | Error logs | |
---|---|---|---|---|
client_code/services/proof.py |
Modify client_code/services/proof.py with contents: • Modify the prove_eligibility function to catch any exceptions when trying to connect to Sismo. If an exception is caught, redirect to the ballot page using the ballot's UUID. |
✅ Commit cdb6293 |
No errors. | |
client_code/forms/routes/vote/ChooseCandidate/__init__.py |
Modify client_code/forms/routes/vote/ChooseCandidate/init.py with contents: • In the __init__ method of the ChooseCandidate class, add a check to see if the proof is valid. If it is not, redirect to the ballot page using the ballot's UUID. |
✅ Commit 9cce0b2 |
No errors. | I have finished coding the issue. I am now reviewing it for completeness. |
Here are my self-reviews of my changes at sweep/fix-redirect-error
.
Here is the 1st review
No changes required. The added code correctly addresses the issue by checking if the proof is not present and redirecting the user to the ballot page if it's not. It also handles exceptions that might occur while connecting to the Sismo client and redirects the user to the ballot page in such cases. Good job!
I finished incorporating these changes.
🎉 Latest improvements to Sweep:
💡 To recreate the pull request edit the issue title or description. Join Our Discord
Details
suppose a ballot is created with an invalid sismo group id. When a user goes to vote, they are sent to sismo to create a zk proof, but this fails because the group does not exist. Sismo then redirects back to electora app, but you get the error:
LookupError: 'vote/choose/<ID>' does not exist
instead, on a failed proof generation (either due to invalid group id or failure to produce a valid proof) the user should be redirected to the ballot page at
#ballot_id=<BALLOT_ID>
Checklist
- [X] `client_code/services/proof.py` > • Modify the `prove_eligibility` function to catch any exceptions when trying to connect to Sismo. If an exception is caught, redirect to the ballot page using the ballot's UUID. - [X] `client_code/forms/routes/vote/ChooseCandidate/__init__.py` > • In the `__init__` method of the `ChooseCandidate` class, add a check to see if the proof is valid. If it is not, redirect to the ballot page using the ballot's UUID.