mathesar icon indicating copy to clipboard operation
mathesar copied to clipboard

Fix erroneous behavior of the constraint endpoint while invalid column ids are passed

Open Anish9901 opened this issue 2 years ago • 1 comments

Description

The following results in a 500 status code.

  • Attempting to set a unique constraint by supplying the id of a column that exists in a different table from the table whose id is supplied in the URL.

  • Non-existent column id, e.g.:

    {"type":"unique","columns":[9999]}
    

Expected behavior

The above should result in a 400(Bad Request) response.

Additional context

See #889, #1406

Anish9901 avatar Oct 06 '22 14:10 Anish9901

The find_key method in the drf-friendly-errors library (https://github.com/FutureMind/drf-friendly-errors/blob/master/rest_framework_friendly_errors/mixins.py#L118) is not parsing the error correctly and ends up returning an incorrect error key. The bug is somewhere in here.

silentninja avatar Oct 11 '22 04:10 silentninja