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:
@@ -84,9 +84,13 @@ def normalize_modal_mode(value: object | None) -> str:
|
||||
|
||||
def has_direct_modal_credentials() -> bool:
|
||||
"""Return True when direct Modal credentials/config are available."""
|
||||
try:
|
||||
modal_file_exists = (Path.home() / ".modal.toml").exists()
|
||||
except (PermissionError, OSError):
|
||||
modal_file_exists = False
|
||||
return bool(
|
||||
(os.getenv("MODAL_TOKEN_ID") and os.getenv("MODAL_TOKEN_SECRET"))
|
||||
or (Path.home() / ".modal.toml").exists()
|
||||
or modal_file_exists
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user