Skip to content

KeyError when using CreateClassificationsSelection on a corpus ID that does not exist

Sentry Issue: ARKINDEX-BACKEND-XD

Corpus.DoesNotExist: Corpus matching query does not exist.
(9 additional frame(s) were not displayed)
...
  File "rest_framework/serializers.py", line 220, in is_valid
    self._validated_data = self.run_validation(self.initial_data)
  File "rest_framework/serializers.py", line 422, in run_validation
    value = self.validate(value)
  File "arkindex/documents/serializers/ml.py", line 197, in validate
  File "django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "django/db/models/query.py", line 435, in get
    raise self.model.DoesNotExist(

The serializer should use a PrimaryKeyRelatedField to let DRF provide the corpus.

This endpoint also makes multiple unnecessary queries, is poorly documented, and its behavior is unclear with the removal of best classes. We need to discuss the future of bulk classification management.

Edited by Erwan Rouchet