Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return 400 errors on deserialization failure #99

Open
rkorsak opened this issue Sep 18, 2020 · 4 comments
Open

Return 400 errors on deserialization failure #99

rkorsak opened this issue Sep 18, 2020 · 4 comments
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest Issues for the Hacktoberfest help wanted Extra attention is needed

Comments

@rkorsak
Copy link
Collaborator

rkorsak commented Sep 18, 2020

Feature Request

Until we have full Pydantic-compliant models (#98), we rely on custom deserialization in the routes, e.g.:

ballots = [PlaintextBallot.from_json_object(ballot) for ballot in request.ballots]

If this deserialization fails, however, it manifests as an opaque 500 error to the client. We should capture deserialization errors and send a 400 with as much information as possible.

@rkorsak rkorsak added the enhancement New feature or request label Sep 18, 2020
@rkorsak rkorsak changed the title Return 400 errors on deserialization failure Return 400 errors on deserialization failure Sep 18, 2020
@keithrfung keithrfung added the hacktoberfest Issues for the Hacktoberfest label Sep 20, 2020
@gagandeepp
Copy link

Interested please assgn

@keithrfung
Copy link
Collaborator

@gagandeepp you got it!

@keithrfung keithrfung added good first issue Good for newcomers help wanted Extra attention is needed labels Oct 7, 2021
@gagandeepp
Copy link

@rkorsak how to reproduce this error?
Also do we need to make changes for all the scenarios in this ticket?

@keithrfung
Copy link
Collaborator

keithrfung commented Oct 8, 2021

@gagandeepp This error can be replicated by passing any model that doesn't match the request model. Using the example:
ballots = [PlaintextBallot.from_json_object(ballot) for ballot in request.ballots]
will fail if there is an issue with ballot object such as a missing field, a string passed instead of a number, etc.

Yes, it should be addressed at all sections where a model is parsed. Probably a wrapping method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest Issues for the Hacktoberfest help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants