Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hermes_cli/kanban_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -3779,7 +3779,7 @@ def _is_managed_scratch_path(p: Path) -> bool:
if override:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This protects the cleanup containment resolver, but workspaces_root() still expands the same HERMES_KANBAN_WORKSPACES_ROOT value without handling RuntimeError (current main: hermes_cli/kanban_db.py:554). Normal scratch resolution calls it, so please cover that sibling path and add a regression test through workspace resolution.

try:
roots.append(Path(override).expanduser().resolve(strict=False))
except OSError:
except (OSError, RuntimeError):
pass
try:
home = kanban_home()
Expand Down
12 changes: 12 additions & 0 deletions tests/hermes_cli/test_kanban_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -2146,6 +2146,18 @@ def test_is_managed_scratch_path_rejects_kanban_metadata_subtrees(kanban_home):
assert kb._is_managed_scratch_path(task_dir)


def test_is_managed_scratch_path_tilde_user_env_does_not_crash(kanban_home, monkeypatch):
"""``HERMES_KANBAN_WORKSPACES_ROOT`` with ``~nonexistent_user`` must not crash.

``Path.expanduser()`` raises ``RuntimeError`` for ``~user`` tokens where
``user`` is not a real account. The workspace-root resolver must swallow
this just like it swallows ``OSError``.
"""
monkeypatch.setenv("HERMES_KANBAN_WORKSPACES_ROOT", "~nonexistent_user/workspace")
# Must not raise β€” the path is simply skipped.
assert not kb._is_managed_scratch_path(Path("/tmp"))


# ---------------------------------------------------------------------------
# Tenancy
# ---------------------------------------------------------------------------
Expand Down
Loading