From 5bcabf446e4058de97b3525d4db6f70b9942e4d7 Mon Sep 17 00:00:00 2001 From: Anika Churilova Date: Tue, 14 May 2024 15:15:50 +0200 Subject: [PATCH] service: add check for draft in update_draft * closes https://github.com/inveniosoftware/product-rdm/issues/178 Co-authored-by: jrcastro2 --- invenio_drafts_resources/services/records/service.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/invenio_drafts_resources/services/records/service.py b/invenio_drafts_resources/services/records/service.py index 925690f..820a621 100644 --- a/invenio_drafts_resources/services/records/service.py +++ b/invenio_drafts_resources/services/records/service.py @@ -258,10 +258,11 @@ def read_latest(self, identity, id_, expand=False): @unit_of_work() def update_draft( - self, identity, id_, data, revision_id=None, uow=None, expand=False + self, identity, id_, data, revision_id=None, uow=None, expand=False, draft=None ): """Replace a draft.""" - draft = self.draft_cls.pid.resolve(id_, registered_only=False) + if draft: + draft = self.draft_cls.pid.resolve(id_, registered_only=False) self.check_revision_id(draft, revision_id)