mathesar
mathesar copied to clipboard
Fix erroneous behavior of the constraint endpoint while invalid column ids are passed
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
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.