Skip to content

Return 400 errors on deserialization failure #99

Open

Description

@rkorsak

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.

Activity

  1. changed the title [-]Return `400` errors on deserialization failure[/-] [+]Return 400 errors on deserialization failure[/+] on Sep 18, 2020
  2. gagandeepp commented on Oct 3, 2021

    @gagandeepp

    Interested please assgn

  3. keithrfung commented on Oct 6, 2021

    @keithrfung
    Contributor

    @gagandeepp you got it!

  4. gagandeepp commented on Oct 8, 2021

    @gagandeepp

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

  5. keithrfung commented on Oct 8, 2021

    @keithrfung
    Contributor

    @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.

  6. removed their assignment
    on Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions