Skip to content

IntegrityError: duplicate key value violates unique constraint "contentcuration_contentnode_tags_contentnode_id_c... #4221

@sentry

Description

@sentry

Occurred when copying files from the clipboard into a channel. The resources copied but the tags failed to copy and caused issues in the UI


Sentry Issue: STUDIO-GHK

UniqueViolation: duplicate key value violates unique constraint "contentcuration_contentnode_tags_contentnode_id_cfa67da1_uniq"
DETAIL:  Key (contentnode_id, contenttag_id)=(9472cb5d6e1a47aeb5c4145f66d53146, 87538e2cbd204993a7f4de0ff4b8f8bc) already exists.

  File "django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "django_prometheus/db/common.py", line 71, in execute
    return super().execute(*args, **kwargs)

IntegrityError: duplicate key value violates unique constraint "contentcuration_contentnode_tags_contentnode_id_cfa67da1_uniq"
DETAIL:  Key (contentnode_id, contenttag_id)=(9472cb5d6e1a47aeb5c4145f66d53146, 87538e2cbd204993a7f4de0ff4b8f8bc) already exists.

(14 additional frame(s) were not displayed)
...
  File "contentcuration/db/models/manager.py", line 383, in copy_node
    return self._copy(
  File "contentcuration/db/models/manager.py", line 413, in _copy
    copied_nodes = self._deep_copy(
  File "contentcuration/db/models/manager.py", line 641, in _deep_copy
    self._copy_associated_objects(source_copy_id_map)
  File "contentcuration/db/models/manager.py", line 563, in _copy_associated_objects
    self._copy_tags(source_copy_id_map)
  File "contentcuration/db/models/manager.py", line 502, in _copy_tags
    self.model.tags.through.objects.bulk_create(mappings_to_create)

Metadata

Metadata

Assignees

Labels

P0 - criticalPriority: Release blocker or regression

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions