splunk / splunk-sdk-python

Splunk Software Development Kit for Python
http://dev.splunk.com
Apache License 2.0
687 stars 369 forks source link

UnicodeDecodeError caught for json_loads #465

Open john-corcoran opened 2 years ago

john-corcoran commented 2 years ago

Hi, I encountered a UnicodeDecodeError when reading some data that was quite badly corrupted. This occurred when iterating through a JSONResultsReader. Error occurred using Python 3.10.5.

Error was:

UnicodeDecodeError: 'utf-8' codec can't decode byte [val] in position [val]: invalid continuation byte

The stacktrace points to json.loads (imported as json_loads) - this pull request catches the exception and re-reads, ignoring the decode error. It may be beneficial to raise a warning to the user, but apologies as I'm not familiar enough with the codebase for that just yet :)