fix(tui_gateway): handle deleted profiles gracefully in _response_profile_name (#107829)
This commit is contained in:
@@ -168,3 +168,16 @@ def test_custom_default_root_real_session_db_owner_stamping(tmp_path, monkeypatc
|
||||
assert launch_db.get_session("lazy-default") is None
|
||||
assert launch_db.get_session("seeded-default") is None
|
||||
assert 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()
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user