fix: JSON loading logs (#30138)

This commit is contained in:
Michael S. Molina 2024-09-03 18:52:30 -03:00 committed by GitHub
parent af066a4630
commit 5c5b4d0f5f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 11 deletions

View File

@ -174,7 +174,11 @@ def validate_json(obj: Union[bytes, bytearray, str]) -> None:
:param obj: an object that should be parseable to JSON
"""
if obj:
loads(obj)
try:
loads(obj)
except JSONDecodeError as ex:
logger.error("JSON is not valid %s", str(ex), exc_info=True)
raise
def dumps( # pylint: disable=too-many-arguments
@ -236,16 +240,12 @@ def loads(
:param object_hook: function that will be called to decode objects values
:returns: A Python object deserialized from string
"""
try:
return simplejson.loads(
obj,
encoding=encoding,
allow_nan=allow_nan,
object_hook=object_hook,
)
except JSONDecodeError as ex:
logger.error("JSON is not valid %s", str(ex), exc_info=True)
raise
return simplejson.loads(
obj,
encoding=encoding,
allow_nan=allow_nan,
object_hook=object_hook,
)
def redact_sensitive(