Skip to content

The agent that grows with you

fix(macos): guard empty DR in TCC check, tighten platform-guard test

David Metcalfe8665b1e4db5a
diff --git a/hermes_cli/doctor.py b/hermes_cli/doctor.py
index adef0d9238d..0cfa71e5932 100644
--- a/hermes_cli/doctor.py
+++ b/hermes_cli/doctor.py
@@ -1066,7 +1066,7 @@ def check_macos_tcc_grants() -> None:
if app is None:
return
dr = _macos_desktop_dr(app)
- if dr is None:
+ if not dr:
check_warn(
"macOS TCC grant check",
"(could not read code-signing requirement of the desktop bundle)",
diff --git a/tests/hermes_cli/test_doctor.py b/tests/hermes_cli/test_doctor.py
index 94ce2c2c801..b2c49c31048 100644
--- a/tests/hermes_cli/test_doctor.py
+++ b/tests/hermes_cli/test_doctor.py
@@ -1522,10 +1522,14 @@ class TestDoctorDeprecatedConfigAndEnv:
class TestMacOSTCCGrants:
"""macOS TCC grant persistence check (issue #86385)."""
- def test_silent_on_non_macos(self, monkeypatch, capsys):
- """Non-macOS: the check must produce no output."""
+ def test_silent_on_non_macos(self, monkeypatch, capsys, tmp_path):
+ """Non-macOS: the check must produce no output even with a bundle present."""
monkeypatch.setattr(doctor_mod.sys, "platform", "linux")
- monkeypatch.setattr(doctor_mod, "_desktop_app_bundle", lambda: None)
+ monkeypatch.setattr(
+ doctor_mod,
+ "_desktop_app_bundle",
+ lambda: tmp_path / "Hermes.app",
+ )
doctor_mod.check_macos_tcc_grants()
assert capsys.readouterr().out == ""
@@ -1587,3 +1591,17 @@ class TestMacOSTCCGrants:
doctor_mod.check_macos_tcc_grants()
out = capsys.readouterr().out
assert "could not read code-signing requirement" in out
+
+ def test_warns_when_dr_empty_string(self, monkeypatch, capsys, tmp_path):
+ """Empty DR output must not false-positive as a stable identity."""
+ monkeypatch.setattr(doctor_mod.sys, "platform", "darwin")
+ monkeypatch.setattr(
+ doctor_mod,
+ "_desktop_app_bundle",
+ lambda: tmp_path / "Hermes.app",
+ )
+ monkeypatch.setattr(doctor_mod, "_macos_desktop_dr", lambda app: "")
+ doctor_mod.check_macos_tcc_grants()
+ out = capsys.readouterr().out
+ assert "could not read code-signing requirement" in out
+ assert "stable" not in out