IntegrityError when sending the same ML class multiple times in CreateClassifications
Sentry Issue: ARKINDEX-BACKEND-4H
UniqueViolation: duplicate key value violates unique constraint "classification_unique_source"
DETAIL: Key (element_id, ml_class_id, source_id)=(d3379c32-b04f-4cc9-87ba-db74af4b50aa, 127e9807-b4cc-4432-8a05-690093d72bb0, 07b4e3fe-cfbb-402f-bbe6-9c37722b248e) already exists.
File "django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
IntegrityError: duplicate key value violates unique constraint "classification_unique_source"
DETAIL: Key (element_id, ml_class_id, source_id)=(d3379c32-b04f-4cc9-87ba-db74af4b50aa, 127e9807-b4cc-4432-8a05-690093d72bb0, 07b4e3fe-cfbb-402f-bbe6-9c37722b248e) already exists.
(16 additional frame(s) were not displayed)
...
File "django/db/backends/utils.py", line 66, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "django/db/backends/utils.py", line 75, in _execute_with_wrappers
return executor(sql, params, many, context)
File "django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
Reproducible using the API client:
cli.request('CreateClassifications', body={
'parent': ELEMENT_ID,
'classifier': SOURCE_SLUG,
'classifications': [
{'class_name': 'lol', 'confidence': 0.5},
{'class_name': 'lol', 'confidence': 0.5},
]
})