Describe the bug
Merging these two agents is failing unexpectedly.
I’ve attached two error messages for merges I’ve attempted (Michael Verlander and Michael Todd). It looks like the foreign key constraint is causing the merge to fail. I believe I was successfully merging agents who were likely to have been considered catalogers before Christmas with no issue. Has there been a change to the system which may now be leading to this?
To Reproduce
Steps to reproduce the behavior:
Go to https://herb32124-edge.test.specifysystems.org/specify/overlay/merge/Agent/?records=299,11910
Merge the two agents
See error
Error:
{
"message" : "Traceback (most recent call last):
File \"/opt/specify7/specifyweb/specify/record_merging.py\", line 47, in resolve_record_merge_response
response = start_function()
File \"/opt/specify7/specifyweb/specify/record_merging.py\", line 389, in <lambda>
lambda: record_merge_fx(model_name, old_model_ids, int(new_model_id), progress, new_record_info))
File \"/usr/lib/python3.8/contextlib.py\", line 75, in inner
return func(*args, **kwds)
File \"/opt/specify7/specifyweb/specify/record_merging.py\", line 315, in record_merge_fx
target_model.objects.get(id=old_model_id).delete()
File \"/opt/specify7/ve/lib/python3.8/site-packages/django/db/models/base.py\", line 966, in delete
collector.collect([self], keep_parents=keep_parents)
File \"/opt/specify7/ve/lib/python3.8/site-packages/django/db/models/deletion.py\", line 302, in collect
raise ProtectedError(
django.db.models.deletion.ProtectedError: (\"Cannot delete some instances of model 'Agent' because they are referenced through protected foreign keys: 'Collectionobject.cataloger'.\", {<Collectionobject: Collectionobject object (200994)>, <Collectionobject: Collectionobject object (200995)>, <Collectionobject: Collectionobject object (201000)>, <Collectionobject: Collectionobject object (201001)>, <Collectionobject: Collectionobject object (201002)>, <Collectionobject: Collectionobject object (201003)>, <Collectionobject: Collectionobject object (201004)>, <Collectionobject: Collectionobject object (201005)>, <Collectionobject: Collectionobject object (201006)>, <Collectionobject: Collectionobject object (201007)>, <Collectionobject: Collectionobject object (201008)>, <Collectionobject: Collectionobject object (201009)>, <Collectionobject: Collectionobject object (201010)>, <Collectionobject: Collectionobject object (201011)>, <Collectionobject: Collectionobject object (201012)>, <Collectionobject: Collectionobject object (201013)>, <Collectionobject: Collectionobject object (201014)>, <Collectionobject: Collectionobject object (201015)>, <Collectionobject: Collectionobject object (201016)>, <Collectionobject: Collectionobject object (201017)>, <Collectionobject: Collectionobject object (201018)>, <Collectionobject: Collectionobject object (201019)>, <Collectionobject: Collectionobject object (201020)>})"
}
Screenshots
https://herb32124-edge.test.specifysystems.org/specify/overlay/merge/Agent/?records=299,11910
failing_merge_michael_todd.mp4
Crash Report
Michael Todd – Merging 6282219c-e2d1-4943-9b44-aac1173469ea Crash Report - 2024-03-25T19_03_12.668Z.txt
Reported by: Royal Botanic Gardens Edinburgh
Describe the bug
Merging these two agents is failing unexpectedly.
To Reproduce
Steps to reproduce the behavior:
Error:
{ "message": "Traceback (most recent call last): File \"/opt/specify7/specifyweb/specify/record_merging.py\", line 47, in resolve_record_merge_response response = start_function() File \"/opt/specify7/specifyweb/specify/record_merging.py\", line 389, in <lambda> lambda: record_merge_fx(model_name, old_model_ids, int(new_model_id), progress, new_record_info)) File \"/usr/lib/python3.8/contextlib.py\", line 75, in inner return func(*args, **kwds) File \"/opt/specify7/specifyweb/specify/record_merging.py\", line 315, in record_merge_fx target_model.objects.get(id=old_model_id).delete() File \"/opt/specify7/ve/lib/python3.8/site-packages/django/db/models/base.py\", line 966, in delete collector.collect([self], keep_parents=keep_parents) File \"/opt/specify7/ve/lib/python3.8/site-packages/django/db/models/deletion.py\", line 302, in collect raise ProtectedError( django.db.models.deletion.ProtectedError: (\"Cannot delete some instances of model 'Agent' because they are referenced through protected foreign keys: 'Collectionobject.cataloger'.\", {<Collectionobject: Collectionobject object (200994)>, <Collectionobject: Collectionobject object (200995)>, <Collectionobject: Collectionobject object (201000)>, <Collectionobject: Collectionobject object (201001)>, <Collectionobject: Collectionobject object (201002)>, <Collectionobject: Collectionobject object (201003)>, <Collectionobject: Collectionobject object (201004)>, <Collectionobject: Collectionobject object (201005)>, <Collectionobject: Collectionobject object (201006)>, <Collectionobject: Collectionobject object (201007)>, <Collectionobject: Collectionobject object (201008)>, <Collectionobject: Collectionobject object (201009)>, <Collectionobject: Collectionobject object (201010)>, <Collectionobject: Collectionobject object (201011)>, <Collectionobject: Collectionobject object (201012)>, <Collectionobject: Collectionobject object (201013)>, <Collectionobject: Collectionobject object (201014)>, <Collectionobject: Collectionobject object (201015)>, <Collectionobject: Collectionobject object (201016)>, <Collectionobject: Collectionobject object (201017)>, <Collectionobject: Collectionobject object (201018)>, <Collectionobject: Collectionobject object (201019)>, <Collectionobject: Collectionobject object (201020)>})" }Screenshots
https://herb32124-edge.test.specifysystems.org/specify/overlay/merge/Agent/?records=299,11910
failing_merge_michael_todd.mp4
Crash Report
Michael Todd – Merging 6282219c-e2d1-4943-9b44-aac1173469ea Crash Report - 2024-03-25T19_03_12.668Z.txt
Reported by: Royal Botanic Gardens Edinburgh