Version or commit:
Current main
Environment:
Ubuntu 24.04 (WSL2), Python 3.12, x86_64
Minimal reproduction:
- Monkeypatch
prep._hf_tree to return a list containing an entry without a "path" key: [{"type": "file", "size": 4096}].
- Call
import_lerobot_dataset with any valid repo_id.
- Observe the crash at
src/hflow/importers/lerobot.py:760.
Expected behavior:
The importer should raise a clean, descriptive ValueError naming the repo_id and the missing field, matching the codebase's established boundary-refusal pattern. It should not crash with a raw KeyError.
Actual behavior:
The importer crashes with a raw stack trace:
File "src/hflow/importers/lerobot.py", line 760, in _ensure_source_archive
if entry.get("type") == "file" and entry["path"].endswith(".parquet"):
KeyError: 'path'
Additional context:
Root cause: _hf_tree (line 513) deliberately tolerates entries without a string "path" using .get("path"), but the episode-parquet loop at line 760 assumes the key exists and uses raw subscript access (entry["path"]).
Why it matters: Every other consumer of the same tree response guards this gap. _fetch_info_json uses .get("path") (line 553), and _episode_metadata_cache_path (lines 594-617) raises a clean ValueError for unsafe paths. This is the single unhardened site in the file.
Fix direction: At the top of the loop, replace entry["path"] with a guarded read. Validate tree_path = entry.get("path") is a non-empty string, else raise a ValueError matching the module's phrasing (e.g., "Hugging Face tree response for {repo_id} lists an entry with no usable 'path'"). No new exception types needed.
Definition of done:
- Add a test in
tests/test_lerobot_metadata_refusals.py following the existing pattern (stub _hf_repo_info + _fetch_info_json, monkeypatch prep._hf_tree).
- Assert
pytest.raises(ValueError, match=...) on the path-less entry.
- Ensure
_assert_no_dataset_output(output_dir) confirms nothing was published.
Version or commit:
Current main
Environment:
Ubuntu 24.04 (WSL2), Python 3.12, x86_64
Minimal reproduction:
prep._hf_treeto return a list containing an entry without a"path"key:[{"type": "file", "size": 4096}].import_lerobot_datasetwith any valid repo_id.src/hflow/importers/lerobot.py:760.Expected behavior:
The importer should raise a clean, descriptive
ValueErrornaming therepo_idand the missing field, matching the codebase's established boundary-refusal pattern. It should not crash with a rawKeyError.Actual behavior:
The importer crashes with a raw stack trace:
Additional context:
Root cause:
_hf_tree(line 513) deliberately tolerates entries without a string"path"using.get("path"), but the episode-parquet loop at line 760 assumes the key exists and uses raw subscript access (entry["path"]).Why it matters: Every other consumer of the same tree response guards this gap.
_fetch_info_jsonuses.get("path")(line 553), and_episode_metadata_cache_path(lines 594-617) raises a cleanValueErrorfor unsafe paths. This is the single unhardened site in the file.Fix direction: At the top of the loop, replace
entry["path"]with a guarded read. Validatetree_path = entry.get("path")is a non-empty string, else raise aValueErrormatching the module's phrasing (e.g.,"Hugging Face tree response for {repo_id} lists an entry with no usable 'path'"). No new exception types needed.Definition of done:
tests/test_lerobot_metadata_refusals.pyfollowing the existing pattern (stub_hf_repo_info+_fetch_info_json, monkeypatchprep._hf_tree).pytest.raises(ValueError, match=...)on the path-less entry._assert_no_dataset_output(output_dir)confirms nothing was published.