From 361c7300dcb6848340fe0319fc4c61b9f2b4d2d7 Mon Sep 17 00:00:00 2001 From: Christoph Ladurner Date: Thu, 13 Jun 2024 09:24:09 +0200 Subject: [PATCH] fix: catch validation error * this change prevents that the rebuild will be stopped completely --- invenio_global_search/components.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/invenio_global_search/components.py b/invenio_global_search/components.py index 0023900..85c4001 100644 --- a/invenio_global_search/components.py +++ b/invenio_global_search/components.py @@ -9,6 +9,7 @@ from collections.abc import Callable +from flask import current_app from flask_principal import Identity from flask_resources import MarshmallowSerializer from invenio_rdm_records.records.api import RDMDraft, RDMRecord @@ -23,6 +24,7 @@ from invenio_records_marc21.services.record import Marc21Metadata from invenio_records_resources.services.records.components import ServiceComponent from invenio_records_resources.services.uow import Operation, UnitOfWork +from marshmallow.exceptions import ValidationError from .serializers import LOMRecordJSONSerializer, Marc21RecordJSONSerializer @@ -61,10 +63,14 @@ def map_metadata_from_a_to_b( "original": original, } - current_records_global_search.records_service.create_or_update( - identity=identity, - data=data, - ) + try: + current_records_global_search.records_service.create_or_update( + identity=identity, + data=data, + ) + except ValidationError as error: + msg = "GLOBAL SEARCH pid: %s has following validation error: %s" + current_app.logger.warning(msg, pid, error) class ComponentOp(Operation):