Self-hosted AI workspace.
Python
fix: logs CLI _resolve crashes on a non-string name (#1631)
Afonso Coutinhof588be4e73c1
diff --git a/scripts/odysseus-logs b/scripts/odysseus-logsindex cb55c7b06..bb2aa4176 100755--- a/scripts/odysseus-logs+++ b/scripts/odysseus-logs@@ -58,6 +58,8 @@ def _resolve(name: str) -> Path | None:"""Match a log by exact filename, basename-without-extension, orsubstring. Returns the most-recently-modified match if there areties."""+ if not isinstance(name, str):+ return Nonecandidates = []for base in (_APP_LOGS, _TMUX_LOGS):if not base.is_dir():diff --git a/tests/test_logs_cli_resolve_nonstring.py b/tests/test_logs_cli_resolve_nonstring.pynew file mode 100644index 000000000..5c7d87c91--- /dev/null+++ b/tests/test_logs_cli_resolve_nonstring.py@@ -0,0 +1,25 @@+"""Regression: logs CLI _resolve must tolerate a non-string name.++`_resolve` did `name in p.name` and `p.name == name`; a non-string `name`+(e.g. None) raised TypeError once any *.log file existed. Non-strings now+return None (no match).+"""+import importlib.machinery+import importlib.util+from pathlib import Path++ROOT = Path(__file__).resolve().parents[1]+++def _load():+ loader = importlib.machinery.SourceFileLoader("odysseus_logs_cli", str(ROOT / "scripts" / "odysseus-logs"))+ spec = importlib.util.spec_from_loader(loader.name, loader)+ m = importlib.util.module_from_spec(spec)+ loader.exec_module(m)+ return m+++def test_non_string_name_returns_none():+ cli = _load()+ assert cli._resolve(None) is None+ assert cli._resolve(123) is None