misc: don't crash on json data sources using lists (#46067)
This commit is contained in:
parent
52800f4173
commit
90834b9402
|
@ -177,6 +177,13 @@ def test_json_datasource(requests_pub, http_requests):
|
|||
json_file.close()
|
||||
assert data_sources.get_items(datasource) == []
|
||||
|
||||
# json file not using dictionaries
|
||||
get_request().datasources_cache = {}
|
||||
json_file = open(json_file_path, 'w')
|
||||
json.dump({'data': [['1', 'foo'], ['2', 'bar']]}, json_file)
|
||||
json_file.close()
|
||||
assert data_sources.get_items(datasource) == []
|
||||
|
||||
# a good json file
|
||||
get_request().datasources_cache = {}
|
||||
json_file = open(json_file_path, 'w')
|
||||
|
|
|
@ -162,6 +162,8 @@ def request_json_items(url, data_source):
|
|||
else:
|
||||
for item in entries.get('data'):
|
||||
# skip malformed items
|
||||
if not isinstance(item, dict):
|
||||
continue
|
||||
if item.get('id') is None or item.get('id') == '':
|
||||
continue
|
||||
if 'text' not in item:
|
||||
|
|
Loading…
Reference in New Issue