From 64b29779ca808119458eb52d0add91a87c9a25b6 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 19 May 2022 11:35:58 +0200 Subject: [PATCH] Fix crash when server sends invalid JSON data If readJSON fails, it puts an entry in the log and then returns None. This then crashes with a TypeError because you can't check for things to be in None. Fixes Sentry issue CURA-3V5. --- plugins/Marketplace/LocalPackageList.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/Marketplace/LocalPackageList.py b/plugins/Marketplace/LocalPackageList.py index ae719b2699..85f835980b 100644 --- a/plugins/Marketplace/LocalPackageList.py +++ b/plugins/Marketplace/LocalPackageList.py @@ -108,7 +108,7 @@ class LocalPackageList(PackageList): :param reply: A reply containing information about a number of packages. """ response_data = HttpRequestManager.readJSON(reply) - if "data" not in response_data: + if response_data is None or "data" not in response_data: Logger.error( f"Could not interpret the server's response. Missing 'data' from response data. Keys in response: {response_data.keys()}") return