Skip to content

The agent that grows with you

fix(plugins): skip dunder dirs without POSIX chmod in the scanner test

Christopherd0c1498a0dd2
diff --git a/hermes_cli/plugins_discovery.py b/hermes_cli/plugins_discovery.py
index 8c2a8451dde..79c9f691fda 100644
--- a/hermes_cli/plugins_discovery.py
+++ b/hermes_cli/plugins_discovery.py
@@ -119,7 +119,10 @@ def scan_directory(
# plugins. Walking them can raise PermissionError and take
# down every subsequent tool call (#86996).
if child.name.startswith("__") and child.name.endswith("__"):
+ logger.debug("Skipping dunder plugin path %s", child)
continue
+ # pathlib.Path.is_dir() swallows OSError, but injected Path-likes
+ # and test doubles can still raise. Fail closed per child.
try:
if not child.is_dir() or (depth == 0 and skip_names and child.name in skip_names):
continue
diff --git a/tests/hermes_cli/test_plugin_scan_dunder_dirs.py b/tests/hermes_cli/test_plugin_scan_dunder_dirs.py
index f409a4be186..cc90dd9c254 100644
--- a/tests/hermes_cli/test_plugin_scan_dunder_dirs.py
+++ b/tests/hermes_cli/test_plugin_scan_dunder_dirs.py
@@ -13,13 +13,10 @@ def test_scan_skips_dunder_dirs_and_still_loads_real_plugin(tmp_path: Path):
demo.mkdir(parents=True)
(demo / "plugin.yaml").write_text("name: demo\nversion: 0.1.0\ndescription: x\n")
(demo / "__pycache__").mkdir()
- pycache = root / "__pycache__"
- pycache.mkdir()
- pycache.chmod(0o000)
- try:
- found = PluginManager()._scan_directory(root, "user")
- finally:
- pycache.chmod(0o700)
+ (root / "__pycache__").mkdir()
+ (root / "__MACOSX__").mkdir()
+
+ found = PluginManager()._scan_directory(root, "user")
assert [manifest.name for manifest in found] == ["demo"]