Skip to content

The agent that grows with you

fix(webapp): read plugin manifests BOM-tolerant and decode git output as UTF-8

unsupportedpastels69da2d7c96d9
diff --git a/hermes_cli/plugins_cmd_inspect.py b/hermes_cli/plugins_cmd_inspect.py
index 006aaccbdfc..9212856cb08 100644
--- a/hermes_cli/plugins_cmd_inspect.py
+++ b/hermes_cli/plugins_cmd_inspect.py
@@ -33,7 +33,7 @@ def _manifest_name(path: Path, loads) -> Optional[str]:
try:
if path.is_symlink() or not path.is_file() or path.stat().st_size > _MANIFEST_MAX_BYTES:
return None
- data = loads(path.read_text(encoding="utf-8"))
+ data = loads(path.read_text(encoding="utf-8-sig"))
except (OSError, UnicodeDecodeError, ValueError, yaml.YAMLError):
return None
name = data.get("name") if isinstance(data, dict) else None
diff --git a/tests/hermes_cli/test_plugins_cmd_inspect.py b/tests/hermes_cli/test_plugins_cmd_inspect.py
index 9c5c495ee4c..b3069a523f0 100644
--- a/tests/hermes_cli/test_plugins_cmd_inspect.py
+++ b/tests/hermes_cli/test_plugins_cmd_inspect.py
@@ -16,7 +16,8 @@ from hermes_cli.plugins_cmd_inspect import inspect_plugin_source
def _git(repo: Path, *args: str) -> str:
- return subprocess.run(["git", *args], cwd=repo, check=True, capture_output=True, text=True).stdout.strip()
+ return subprocess.run(["git", *args], cwd=repo, check=True, capture_output=True, text=True, encoding="utf-8",
+ errors="replace").stdout.strip()
def _repo(tmp_path: Path, files: dict[str, str], name: str = "source") -> Path: