Skip to content

AttributeError when calling CreateClassifications without a worker version or worker run ID

Sentry Issue: ARKINDEX-BACKEND-1CM

AttributeError: 'NoneType' object has no attribute 'id'
(8 additional frame(s) were not displayed)
...
  File "rest_framework/generics.py", line 190, in post
    return self.create(request, *args, **kwargs)
  File "rest_framework/mixins.py", line 19, in create
    self.perform_create(serializer)
  File "rest_framework/mixins.py", line 24, in perform_create
    serializer.save()
  File "rest_framework/serializers.py", line 205, in save
    self.instance = self.create(validated_data)
  File "arkindex/documents/serializers/ml.py", line 688, in create

CreateClassifications requires either a worker version ID in worker_version or a worker run ID in worker_run_id. Before the transition to worker runs started, it was documented that worker_version was required, but now the only way to document and validate this is to do so manually as the concept of a field depending on another is quite complex in OpenAPI.

We can either allow manual classifications or require a worker version or worker run to be set, both of which are easy to implement.