Skip to content

fix: recover from invalid default workspace paths (closes #366) - #372

Merged
nesquena-hermes merged 2 commits into
masterfrom
pr-366-review
Apr 13, 2026
Merged

nesquena-hermes merged 2 commits into
masterfrom
pr-366-review

Conversation

@nesquena-hermes

Copy link
Copy Markdown
Collaborator

Summary

Merges PR #366 by @Jordan-SkyLF. Rebased onto current master (was 2 releases behind). 5 additional tests added.

What the PR does

Hardens workspace path resolution in api/config.py. Previously, if default_workspace pointed to a non-existent or unwritable path (deleted directory, bad environment variable, stale settings), the server would either crash at startup or silently carry an unusable workspace. Now:

  • _workspace_candidates() builds a priority-ordered list of fallback paths
  • _ensure_workspace_dir() validates + creates each candidate
  • resolve_default_workspace() returns the first usable path or raises RuntimeError with a clear message
  • save_settings() validates the workspace before persisting it
  • Startup normalizes stale settings file entries on first run

Tests

7 tests total in tests/test_default_workspace_fallback.py (2 original + 5 added):

  • Fallback to ~/work when primary path unusable
  • save_settings rewrites bad workspace to fallback
  • ~/workspace created when nothing else exists
  • RuntimeError raised when all candidates fail
  • Deduplication: ~/workspace appears at most once in candidates list
  • Env var HERMES_WEBUI_DEFAULT_WORKSPACE takes priority over None raw arg
  • _ensure_workspace_dir returns False for unwritable paths

Test results: 922/922

Jordan-SkyLF and others added 2 commits April 13, 2026 21:25
(cherry picked from commit 789d7537a325d1c7d3aa03c387918dddd2d0897d)
#366)

- tests/test_default_workspace_fallback.py: 5 additional tests (dedup,
  RuntimeError, env var priority, mkdir on missing dir, unwritable path)
- CHANGELOG.md: v0.50.18 entry; 922 tests (up from 915)
@nesquena-hermes
nesquena-hermes merged commit 6842612 into master Apr 13, 2026
3 checks passed
@nesquena-hermes
nesquena-hermes deleted the pr-366-review branch April 13, 2026 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants