Skip to content

IntegrityError: duplicate key value violates unique constraint "modelversion_unique_hash"

Steps to reproduce:

  • open https://arkindex.teklia.com/api/v1/model/<model_id>/versions/
  • create a new version with {"archive_hash": "<hexdigest>", "hash": "<hexdigest>", "size": <int>}
  • try to create another version with the same payload
  • backend returns a 500 with the integrity error

Sentry Issue: ARKINDEX-BACKEND-2TJ

UniqueViolation: duplicate key value violates unique constraint "modelversion_unique_hash"
DETAIL:  Key (model_id, hash)=(53584817-12b0-4d71-a66e-d016781d97ba, 594f803b380a41396ed63dca39503551) already exists.
  File "django/db/backends/utils.py", line 105, in _execute
    return self.cursor.execute(sql, params)
  File "psycopg/cursor.py", line 97, in execute
    raise ex.with_traceback(None)

IntegrityError: duplicate key value violates unique constraint "modelversion_unique_hash"
DETAIL:  Key (model_id, hash)=(53584817-12b0-4d71-a66e-d016781d97ba, 594f803b380a41396ed63dca39503551) already exists.
(25 additional frame(s) were not displayed)
...
  File "arkindex/training/api.py", line 195, in create