Skip to content

Ensure all field validators return 400 with helpful message #646

@mihow

Description

@mihow

@annavik discovered that the field validators for GET parameters and other user-passed values are returning 500 errors instead of 400's. Also the error message data does not specify which field has a validation issue. This is because we are using Django's form field validators instead of the Django Rest Framework validators (from its serializers). Two examples that fixe this issue were introduced in #643, and this pattern needs to be applied to other cases where we are importing from django.forms (IntegerField, DateField, etc.). In general, the solution is to always make a serializer, and then call is_valid() on the serializer, which will raise a 400 error with a detailed & structured message about each field.

Also in the case that a 500 is still returned from the backend, it is possible that the response has some error information. We frontend should be able to display that as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions