The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tui_gateway): handle deleted profiles gracefully in _response_profile_name (#107829)
salch-cred8f6afbaf0d48
diff --git a/tests/tui_gateway/test_default_profile_session_name.py b/tests/tui_gateway/test_default_profile_session_name.pyindex 16767354a4c..953d19d56f1 100644--- a/tests/tui_gateway/test_default_profile_session_name.py+++ b/tests/tui_gateway/test_default_profile_session_name.py@@ -168,3 +168,16 @@ def test_custom_default_root_real_session_db_owner_stamping(tmp_path, monkeypatcassert launch_db.get_session("lazy-default") is Noneassert launch_db.get_session("seeded-default") is Noneassert launch_db.get_session("branched-default") is None+++def test_deleted_profile_falls_back_to_current_profile(tmp_path, monkeypatch):+ """Deleted/non-existent profiles must not raise FileNotFoundError in _response_profile_name."""+ from tui_gateway import server++ default_home, launch_home = _profile_layout(tmp_path)+ monkeypatch.setattr(Path, "home", lambda: tmp_path)+ monkeypatch.setenv("HERMES_HOME", str(launch_home))+ monkeypatch.setattr(server, "_hermes_home", launch_home)++ assert server._response_profile_name("non-existent-profile-123") == server._current_profile_name()+diff --git a/tui_gateway/server.py b/tui_gateway/server.pyindex 91faeb3caf6..195f572a207 100644--- a/tui_gateway/server.py+++ b/tui_gateway/server.py@@ -474,7 +474,12 @@ def _canonical_profile_request(name: str) -> str:def _response_profile_name(profile: str | None = None) -> str:"""Profile name for session.* payloads: the requested real non-launch profile, else the launch one."""name = _canonical_profile_request((profile or "").strip())- return name if name and _profile_home(name) is not None else _current_profile_name()+ if not name:+ return _current_profile_name()+ try:+ return name if _profile_home(name) is not None else _current_profile_name()+ except FileNotFoundError:+ return _current_profile_name()def _db_unavailable_error(rid, *, code: int):