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.
This commit is contained in:
Ghostkeeper 2022-05-19 11:35:58 +02:00
parent c41c59da13
commit 64b29779ca
No known key found for this signature in database
GPG Key ID: 68F39EA88EEED5FF

View File

@ -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