Skip to content

fix(tools): guard Path.home() against PermissionError in has_direct_modal_credentials - #33528

Merged
benbarclay merged 1 commit into
NousResearch:mainfrom
liuhao1024:fix/modal-credentials-permission-error
May 29, 2026
Merged

fix(tools): guard Path.home() against PermissionError in has_direct_modal_credentials#33528
benbarclay merged 1 commit into
NousResearch:mainfrom
liuhao1024:fix/modal-credentials-permission-error

Conversation

@liuhao1024

Copy link
Copy Markdown
Contributor

What does this PR do?

Guards Path.home() / ".modal.toml" in has_direct_modal_credentials() against PermissionError (and OSError).

When Hermes runs in Docker containers with HOME=/root but the process is the unprivileged hermes user (uid 10000), Path.home() resolves to /root/. Calling .exists() on a path under /root/ raises PermissionError: [Errno 13] Permission denied: '/root/.modal.toml'. This crashes the dashboard /api/skills endpoint.

Why

The has_direct_modal_credentials() function is called during skills page load (line 4479 in web_server.py) to evaluate tool requirements. In Docker, the dashboard service inherits HOME=/root from the container environment but runs as hermes user who can't read /root/.

Changes

tools/tool_backend_helpers.py (1 file):

  • Wrap Path.home() / ".modal.toml" in try/except (PermissionError, OSError)
  • On error, treat as "no config file" — env vars still take priority

tests/tools/test_tool_backend_helpers.py (1 file):

  • test_home_dir_permission_denied: verifies PermissionError returns False when no env vars set
  • test_home_dir_permission_denied_with_env_vars: verifies env vars still work when Path.home() raises

Testing

All 49 tests in test_tool_backend_helpers.py pass, including the 2 new ones:

  • test_home_dir_permission_deniedPermissionErrorFalse (no env vars)
  • test_home_dir_permission_denied_with_env_varsPermissionErrorTrue (env vars set)

Related

Fixes #33525

Code Intelligence

  • Analyzed: tools/tool_backend_helpers.py:has_direct_modal_credentials (callers: web_server.py skills endpoint, test_tool_backend_helpers.py, test_nous_subscription.py)
  • Blast radius: LOW — single function, defensive change, no behavior change for non-Docker environments
  • Related patterns: Path.home() usage in Docker containers with mixed user contexts

…odal_credentials

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 NousResearch#33525
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/tools Tool registry, model_tools, toolsets area/docker Docker image, Compose, packaging backend/modal Modal.com cloud execution labels May 27, 2026
@benbarclay
benbarclay merged commit 44df520 into NousResearch:main May 29, 2026
18 of 20 checks passed
KKT-OPT pushed a commit to KKT-OPT/hermes-agent that referenced this pull request May 31, 2026
…odal_credentials (NousResearch#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 NousResearch#33525
alt-glitch pushed a commit that referenced this pull request Jun 14, 2026
…odal_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
T02200059 pushed a commit to T02200059/hermes-agent that referenced this pull request Jun 18, 2026
…odal_credentials (NousResearch#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 NousResearch#33525
xyshanren pushed a commit to xyshanren/hermes-agent-cn that referenced this pull request Jun 25, 2026
…odal_credentials (NousResearch#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 NousResearch#33525
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
…odal_credentials (NousResearch#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 NousResearch#33525
santhreal pushed a commit to santhreal/hermes-agent that referenced this pull request Jul 13, 2026
…odal_credentials (NousResearch#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 NousResearch#33525
donbowman pushed a commit to donbowman/hermes-agent that referenced this pull request Jul 13, 2026
…odal_credentials (NousResearch#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 NousResearch#33525
Gravezzz pushed a commit to Gravezzz/hermes-agent that referenced this pull request Jul 21, 2026
…odal_credentials (NousResearch#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 NousResearch#33525
leewenjie pushed a commit to leewenjie/hermes-agent that referenced this pull request Aug 7, 2026
…odal_credentials (NousResearch#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 NousResearch#33525
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docker Docker image, Compose, packaging backend/modal Modal.com cloud execution comp/tools Tool registry, model_tools, toolsets P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dashboard skills page crashes with PermissionError when HOME=/root

3 participants