Unhandled IntegrityError when POSTing to /api/metadata/document/{pk}/metadata/ with an existing `metadata_type_pk`
The /api/metadata/document/{pk}/metadata/ endpoint requires a metadata_type_pk
and a value
argument. If trying to POST a second time to the same endpoint with a metadata_type_pk
that has already been set for the given document, an unhandled IntegrityError
is raised (due to this constraint: unique_together = ('document', 'metadata_type')
).
It would be nicer to handle this error and return a proper HTTP error code with error message instead of a 500
.