Forbid creating new worker results with worker version IDs
Closes #1420 (closed)
- This uses two different strategies to implement read-only forbidden fields and write-only forbidden fields:
- On all endpoints where nobody is using the returned worker version ID, the field has been completely removed, and a
ForbiddenField()
is used instead. The field is never returned in the response, and using it in the request body causes an error. - On all endpoints where the worker version ID might still be used, which happens often with the frontend as it stores the result of the API request directly into the store, the worker version ID fields are replaced with a basic
UUIDField
with aForbiddenValidator()
: the worker version ID is still included in the response, but using it in the request body will cause an error. This also means we cannot document that those are read-only in OpenAPI.
- On all endpoints where nobody is using the returned worker version ID, the field has been completely removed, and a
- Sending a worker version ID of
None
cannot be detected due to how DRF validates null values before any custom validation can happen, and changing this requires way too much effort for the benefit it could give here. Since sendingNone
implies you want to create something manual or something with a worker run ID anyway, it doesn't matter much. - On bulk endpoints, where a worker run will be required, it is now properly marked as
required
in the OpenAPI docs and DRF will throw basicThis field is required.
errors. - All
worker_version
andworker_version_id
fields in the relevant endpoints are now also marked asdeprecated
. - The
ValidateClassification
andRejectClassification
endpoints were not actually relevant to this MR. These endpoints do not take in any request body, but the OpenAPI documentation was saying that they were because DRF and Spectacular were not expecting their weirdness. I just removed the useless request bodies for them. - I added a whole bunch of
assertNumQueries
and other assertions in the tests I was updating as there were a lot of places where I could not properly verify what I was doing… -
⚠ Merging this breaks the PDF text import (both from a DataFile and from S3) and the Transkribus import
Edited by Erwan Rouchet