Calling HfFileSystem().ls(some_repo_id) throws a KeyError with all repositories I've tried. This wasn't happening yesterday and switching to an older huggingface_hub version does not seem to help.
# before
safe=security["safe"], av_scan=security["avScan"], pickle_import_scan=security["pickleImportScan"]
# after
safe=security['hf']["safe"], av_scan=security['hf']["avScan"], pickle_import_scan=security['hf']["pickleImportScan"]
Traceback (most recent call last):
File "/tmp/test.py", line 4, in <module>
files = HfFileSystem().ls(id_repo)
File "/tmp/venv/lib/python3.10/site-packages/huggingface_hub/hf_file_system.py", line 292, in ls
out = self._ls_tree(path, refresh=refresh, revision=revision, **kwargs)
File "/tmp/venv/lib/python3.10/site-packages/huggingface_hub/hf_file_system.py", line 383, in _ls_tree
for path_info in tree:
File "/tmp/venv/lib/python3.10/site-packages/huggingface_hub/hf_api.py", line 2913, in list_repo_tree
yield (RepoFile(**path_info) if path_info["type"] == "file" else RepoFolder(**path_info))
File "/tmp/venv/lib/python3.10/site-packages/huggingface_hub/hf_api.py", line 638, in __init__
safe=security["safe"], av_scan=security["avScan"], pickle_import_scan=security["pickleImportScan"]
KeyError: 'safe'
Describe the bug
Calling
HfFileSystem().ls(some_repo_id)
throws a KeyError with all repositories I've tried. This wasn't happening yesterday and switching to an older huggingface_hub version does not seem to help.The object throwing the KeyError seems to come from the security field in this API response: https://huggingface.co/api/models/tiiuae/falcon-7b-instruct/tree/main?expand=True (Code doesn't seem to be expecting everything to be wrapped in an
hf
field)As a workaround, changing this line in hf_api.py seems to fix things.
Reproduction
Logs
Response from https://huggingface.co/api/models/tiiuae/falcon-7b-instruct/tree/main?expand=True
System info