Fix validation error causes infinite loop

This commit is contained in:
allegroai 2021-12-04 23:21:16 +02:00
parent 8c50f34f8c
commit 13a1472b68

View File

@ -2,6 +2,7 @@ import abc
import requests.exceptions
import six
import jsonschema
from ..backend_api import Session, CallResult
from ..backend_api.session.session import MaxRequestSizeError
@ -15,6 +16,10 @@ from ..debugging import get_logger
from .session import SendError, SessionInterface
class ValidationError(ValueError):
pass
class InterfaceBase(SessionInterface):
""" Base class for a backend manager class """
_default_session = None
@ -78,6 +83,15 @@ class InterfaceBase(SessionInterface):
if raise_on_errors:
raise
res = None
except jsonschema.ValidationError as e:
if log:
log.error(
'Field %s contains illegal schema: %s', '.'.join(e.path), str(e.message)
)
if raise_on_errors:
raise ValidationError(f"Field {'.'.join(e.path)} contains illegal schema: {e.message}")
# We do not want to retry
return None
except Exception as e:
res = None
if log and num_retries >= cls._num_retry_warning_display: