Browse Source

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.
Ghostkeeper 2 years ago
parent
commit
64b29779ca
1 changed files with 1 additions and 1 deletions
  1. 1 1
      plugins/Marketplace/LocalPackageList.py

+ 1 - 1
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