From cf7d61e9b4faef0298094a97009db7695e0c5009 Mon Sep 17 00:00:00 2001 From: Carlin MacKenzie Date: Wed, 6 Nov 2024 17:01:31 +0100 Subject: [PATCH] bug: fix case where record is None --- invenio_rdm_records/services/components/pids.py | 5 +++-- invenio_rdm_records/services/pids/tasks.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/invenio_rdm_records/services/components/pids.py b/invenio_rdm_records/services/components/pids.py index 420153429..f566854e6 100644 --- a/invenio_rdm_records/services/components/pids.py +++ b/invenio_rdm_records/services/components/pids.py @@ -17,7 +17,7 @@ from invenio_drafts_resources.services.records.uow import ParentRecordCommitOp from invenio_records_resources.services.uow import TaskOp -from ..pids.tasks import register_or_update_pid, cleanup_parent_pids +from ..pids.tasks import cleanup_parent_pids, register_or_update_pid class PIDsComponent(ServiceComponent): @@ -216,7 +216,8 @@ def delete_record(self, identity, data=None, record=None, uow=None): # We're sending a task in case there is a race condition with two # versions being deleted at the same time to ensure that we have # consistent database state - self.uow.register(TaskOp(cleanup_parent_pids, record["id"])) + if record: + self.uow.register(TaskOp(cleanup_parent_pids, record)) # Async register/update tasks after transaction commit. for scheme in parent_pids.keys(): diff --git a/invenio_rdm_records/services/pids/tasks.py b/invenio_rdm_records/services/pids/tasks.py index 2c13f882d..067f59cba 100644 --- a/invenio_rdm_records/services/pids/tasks.py +++ b/invenio_rdm_records/services/pids/tasks.py @@ -28,7 +28,7 @@ def register_or_update_pid(recid, scheme, parent=False): @shared_task(ignore_result=True) def cleanup_parent_pids(record): - """Clean up parent PIDs which could not be deleted by the service.""" + """Clean up parent PIDs.""" record_cls = current_rdm_records.records_service parent_pids = copy(record.parent.get("pids", {})) if record_cls.next_latest_published_record_by_parent(record.parent) is None: