Im trying to make use of the api specifically the delete endpoint for attachments and collectionobjectattachments.
When trying to delete the collectionobjectattachment i get this error back:
{"exception": "AssertionError", "message": "attempt to add object with null id to audit log", "data": "None", "traceback": "Traceback (most recent call last):\n File \"/opt/specify7/ve/lib/python3.8/site-packages/django/core/handlers/base.py\", line 181, in _get_response\n response = wrapped_callback(request, *callback_args, **callback_kwargs)\n File \"/opt/specify7/specifyweb/specify/views.py\", line 34, in wrapped\n return view(request, *args, **kwargs)\n File \"/opt/specify7/ve/lib/python3.8/site-packages/django/views/decorators/cache.py\", line 31, in _cache_controlled\n response = viewfunc(request, *args, **kw)\n File \"/opt/specify7/specifyweb/specify/views.py\", line 70, in view\n return dispatch_func(request, *args, **kwargs)\n File \"/opt/specify7/specifyweb/specify/api.py\", line 177, in resource_dispatch\n delete_resource(request.specify_collection,\n File \"/usr/lib/python3.8/contextlib.py\", line 75, in inner\n return func(*args, **kwds)\n File \"/opt/specify7/specifyweb/specify/api.py\", line 636, in delete_resource\n return delete_obj(obj, version, collection=collection, agent=agent)\n File \"/opt/specify7/specifyweb/specify/api.py\", line 660, in delete_obj\n delete_obj(dep, version, parent_obj=obj, collection=collection, agent=agent, clean_predelete=clean_predelete)\n File \"/opt/specify7/specifyweb/specify/api.py\", line 650, in delete_obj\n auditlog.remove(obj, agent, parent_obj)\n File \"/opt/specify7/specifyweb/specify/auditlog.py\", line 63, in remove\n log_obj = self._log(auditcodes.REMOVE, obj, agent, parent_record)\n File \"/opt/specify7/specifyweb/specify/auditlog.py\", line 89, in _log\n assert obj.id is not None, \"attempt to add object with null id to audit log\"\nAssertionError: attempt to add object with null id to audit log\n"}
Describe the bug
When trying to remove an attachment or
{table}attachment(e.g.collectionobjectattachment,collectingeventattachment, etc.) record via the API (both via direct API delete and using the "delete" button on the data entry forms), it fails.To Reproduce
Steps to reproduce the behavior:
Go to a
CollectionObjectAttachmentrecord directly (can grab the direct URL from the form meta menu when viewing an attachment)Attempt to delete it
See error:
AssertionErrorDelete.mov
Go to the associated
Attachmentrecord directly (or any attachment record linked to a joining{table}attachmentrecord)Attempt to delete it
See error:
Expected behavior
Deleting a
collectionobjectattachmentshould delete theattachmentrecord as long as it is not referenced anywhere else (attachments can be shared with multiple join records).Deleting an
attachmentrecord should delete all associated{table}attachmentrecords.In both cases, it should not result in an error and the actual attachment file should be deleted.
Crash Report
Specify 7 System Information - 2025-07-01T16_14_24.296Z.txt
v711-prereleaseandv7.10.2.3,sp7demofishabb2d47Reported By
NHMD via the Speciforum