Skip to content

Agent Merging delete.ProtectedError for linked records #6895

@bronwyncombs

Description

@bronwyncombs

Describe the bug

Paul Blom reported agent merging failure and sent the crash reports included below. The error message is as follows:

deletion.ProtectedError: ("Cannot delete some instances of model 'Agent' because they are referenced through protected foreign keys: 'Address.createdbyagent', 'Address.modifiedbyagent', 'Agentspecialty.createdbyagent', 'Agentspecialty.modifiedbyagent'.", {<Address: Address object (33)>, <Agentspecialty: Agentspecialty object (1)>, <Agentspecialty: Agentspecialty object (2)>, <Agentspecialty: Agentspecialty object (3)>, <Agentspecialty: Agentspecialty object (4)>, <Agentspecialty: Agentspecialty object (5)>, <Agentspecialty: Agentspecialty object (6)>, <Agentspecialty: Agentspecialty object (7)>, <Agentspecialty: Agentspecialty object (8)>, <Address: Address object (25)>, <Address: Address object (28)>, <Address: Address object (29)>, <Address: Address object (30)>, <Address: Address object (31)>} 

This error is related to PR #4699 and Issue #4685. The potential of this error remaining for other cases is mentioned in @melton-jason #4699 (comment)

While this issue and the one mentioned in #4685 (comment) only
mention CollectionObject -> Cataloger, the Issue still likely applies in similar relationships from Agent (untested).

The concern with this case, especially, is that the preventing fields are read-only, and thus can't be easily edited to workaround the merging error.

To Reproduce
Steps to reproduce the behavior:

  1. Find agent records where at least one is referenced as on Address or AgentSpecialty records for other Agents (or replicate reporting issue with test panel and crash report)
  2. Attempt merge
  3. See Error

Expected behavior
Successful merge

Crash Report
Merging.79770e27-ae5a-4c5e-92eb-d28311ab500f.Crash.Report.-.2024-07-09T17_55_58.633Z.txt

Please fill out the following information manually:

Reported By

Paul Blom @ Orma J. Smith Museum of Natural History - The College of Idaho

Additional Context

Linked Record button in the merge dialog shows the count of all linked records and their tables. Clicking a table/field's count allows browse in forms of those records.

Image Image

Although this doesn't reveal which links may prevent a successful merge from this, it is a helpful way to easily view and access linked records for a given agent.

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions