mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-08 08:11:38 +00:00
fix(tools): guard Path.home() against PermissionError in has_direct_modal_credentials (#33528)
When HOME=/root (Docker containers) and the process runs as unprivileged user (hermes, uid 10000), Path.home() / '.modal.toml' raises PermissionError because /root/ is inaccessible. This crashes the dashboard /api/skills endpoint. Catch PermissionError/OSError and treat as 'no config file'. Env vars still take priority (tested). Fixes #33525
This commit is contained in:
parent
9992e32db3
commit
44df52005a
2 changed files with 19 additions and 1 deletions
|
|
@ -242,6 +242,20 @@ class TestHasDirectModalCredentials:
|
|||
with patch.object(Path, "home", return_value=tmp_path):
|
||||
assert has_direct_modal_credentials() is True
|
||||
|
||||
def test_home_dir_permission_denied(self, monkeypatch):
|
||||
"""PermissionError on Path.home() should not crash (issue #33525)."""
|
||||
monkeypatch.delenv("MODAL_TOKEN_ID", raising=False)
|
||||
monkeypatch.delenv("MODAL_TOKEN_SECRET", raising=False)
|
||||
with patch.object(Path, "home", side_effect=PermissionError("denied")):
|
||||
assert has_direct_modal_credentials() is False
|
||||
|
||||
def test_home_dir_permission_denied_with_env_vars(self, monkeypatch):
|
||||
"""PermissionError on Path.home() should not prevent env var detection."""
|
||||
monkeypatch.setenv("MODAL_TOKEN_ID", "id-123")
|
||||
monkeypatch.setenv("MODAL_TOKEN_SECRET", "sec-456")
|
||||
with patch.object(Path, "home", side_effect=PermissionError("denied")):
|
||||
assert has_direct_modal_credentials() is True
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# prefers_gateway
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue