Fix unhandled exception for non dictionary items in extensions repo
Ensure items in the repository list are dictionaries.
This commit is contained in:
committed by
Philipp Oeser
parent
9d99422091
commit
ffa8243158
@@ -1343,7 +1343,7 @@ def pkg_manifest_params_compatible_or_error(
|
||||
return None
|
||||
|
||||
|
||||
def repository_filter_packages(
|
||||
def repository_parse_data_filtered(
|
||||
data: List[Dict[str, Any]],
|
||||
*,
|
||||
repo_directory: str,
|
||||
@@ -1352,6 +1352,10 @@ def repository_filter_packages(
|
||||
) -> Dict[str, PkgManifest_Normalized]:
|
||||
pkg_manifest_map = {}
|
||||
for item in data:
|
||||
if not isinstance(item, dict):
|
||||
error_fn(Exception("found non dict item in repository \"data\", found {:s}".format(str(type(item)))))
|
||||
continue
|
||||
|
||||
if (pkg_idname := repository_id_with_error_fn(
|
||||
item,
|
||||
repo_directory=repo_directory,
|
||||
@@ -1531,7 +1535,7 @@ class _RepoDataSouce_JSON(_RepoDataSouce_ABC):
|
||||
data = RepoRemoteData(
|
||||
version=data_dict.get("version", "v1"),
|
||||
blocklist=data_dict.get("blocklist", []),
|
||||
pkg_manifest_map=repository_filter_packages(
|
||||
pkg_manifest_map=repository_parse_data_filtered(
|
||||
data_dict.get("data", []),
|
||||
repo_directory=os.path.dirname(self._filepath),
|
||||
filter_params=self._filter_params,
|
||||
|
||||
@@ -2608,6 +2608,9 @@ def pkg_repo_data_from_json_or_error(json_data: Dict[str, Any]) -> Union[PkgRepo
|
||||
|
||||
if not isinstance((data := json_data.get("data", [])), list):
|
||||
return "expected \"data\" to be a list"
|
||||
for item in data:
|
||||
if not isinstance(item, dict):
|
||||
return "expected \"data\" contain dictionary items"
|
||||
|
||||
result_new = PkgRepoData(
|
||||
version=version,
|
||||
|
||||
Reference in New Issue
Block a user