Skip to content

Commit

Permalink
Fixed an issue with "KeyError: 'versions'" when dependency does not e…
Browse files Browse the repository at this point in the history
…xist in the registry // Resolve #3666
  • Loading branch information
ivankravets committed Sep 11, 2020
1 parent ea21f3f commit 7bc170a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
5 changes: 5 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ PlatformIO Core 5

**A professional collaborative platform for embedded development**

5.0.2 (2020-09-??)
~~~~~~~~~~~~~~~~~~

- Fixed an issue with "KeyError: 'versions'" when dependency does not exist in the registry (`issue #3666 <https://github.com/platformio/platformio-core/issues/3666>`_)

5.0.1 (2020-09-10)
~~~~~~~~~~~~~~~~~~

Expand Down
2 changes: 1 addition & 1 deletion platformio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import sys

VERSION = (5, 0, 1)
VERSION = (5, 0, "2a1")
__version__ = ".".join([str(s) for s in VERSION])

__title__ = "platformio"
Expand Down
9 changes: 4 additions & 5 deletions platformio/clients/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,7 @@ def send_request(self, method, path, **kwargs):
def fetch_json_data(self, method, path, **kwargs):
cache_valid = kwargs.pop("cache_valid") if "cache_valid" in kwargs else None
if not cache_valid:
return self.raise_error_from_response(
self.send_request(method, path, **kwargs)
)
return self._parse_json_response(self.send_request(method, path, **kwargs))
cache_key = ContentCache.key_from_args(
method, path, kwargs.get("params"), kwargs.get("data")
)
Expand All @@ -144,11 +142,12 @@ def fetch_json_data(self, method, path, **kwargs):
if result is not None:
return json.loads(result)
response = self.send_request(method, path, **kwargs)
data = self._parse_json_response(response)
cc.set(cache_key, response.text, cache_valid)
return self.raise_error_from_response(response)
return data

@staticmethod
def raise_error_from_response(response, expected_codes=(200, 201, 202)):
def _parse_json_response(response, expected_codes=(200, 201, 202)):
if response.status_code in expected_codes:
try:
return response.json()
Expand Down

0 comments on commit 7bc170a

Please sign in to comment.