From 4e7d88311fbb5a41a7837387e2b49256d8380041 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Thu, 21 Feb 2019 20:42:51 -0300 Subject: [PATCH] raise proper exception on undecode-able blobs --- lbrynet/stream/descriptor.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lbrynet/stream/descriptor.py b/lbrynet/stream/descriptor.py index ad676a38e..80d067ca4 100644 --- a/lbrynet/stream/descriptor.py +++ b/lbrynet/stream/descriptor.py @@ -131,7 +131,10 @@ class StreamDescriptor: assert os.path.isfile(blob.file_path) with open(blob.file_path, 'rb') as f: json_bytes = f.read() - decoded = json.loads(json_bytes.decode()) + try: + decoded = json.loads(json_bytes.decode()) + except json.JSONDecodeError: + raise InvalidStreamDescriptorError("Does not decode as valid JSON") if decoded['blobs'][-1]['length'] != 0: raise InvalidStreamDescriptorError("Does not end with a zero-length blob.") if any([blob_info['length'] == 0 for blob_info in decoded['blobs'][:-1]]):