Skip to content

Replay your coding agent sessions as a map and a timeline

fix(cli): bound numeric fix targets; test historical id precedence

aiswaryasankartest49c97ae605ef
diff --git a/python/src/agentplay/cli.py b/python/src/agentplay/cli.py
index 3409746..5c4bc56 100644
--- a/python/src/agentplay/cli.py
+++ b/python/src/agentplay/cli.py
@@ -341,7 +341,8 @@ def _pick_fix(st: Store, items: list[dict], target: str) -> dict | None:
by_id = next((f for f in items if f["id"] == target), None)
if by_id is None and len(target) == 12:
by_id = next((f for f in _health_fixes(st, days=36500) if f["id"] == target), None)
- if by_id is not None or not target.isdigit():
+ # Bounded before int(): a huge digit string would raise rather than be rejected.
+ if by_id is not None or not target.isdigit() or len(target.lstrip("0")) > 6:
return by_id
n = int(target)
return items[n - 1] if 1 <= n <= len(items) else None
diff --git a/python/tests/test_search_health_fixes.py b/python/tests/test_search_health_fixes.py
index 131e6ac..5239eab 100644
--- a/python/tests/test_search_health_fixes.py
+++ b/python/tests/test_search_health_fixes.py
@@ -400,8 +400,12 @@ def test_an_all_digit_fix_id_is_matched_before_a_list_number(monkeypatch):
assert cli._pick_fix(None, items, "123456789012")["id"] == "123456789012"
assert cli._pick_fix(None, items, "1")["id"] == "aaaaaaaaaaaa"
assert cli._pick_fix(None, items, "0") is None
+ # A historical id wins over the list position the same digits would name.
+ monkeypatch.setattr(cli, "_health_fixes", lambda *_a, **_k: [{"id": "000000000001"}])
+ assert cli._pick_fix(None, items, "000000000001") == {"id": "000000000001"}
monkeypatch.setattr(cli, "_health_fixes", lambda *_a, **_k: [])
assert cli._pick_fix(None, items, "000000000002")["id"] == "123456789012" # zero-padded number
+ assert cli._pick_fix(None, items, "9" * 5000) is None # rejected, not a ValueError
def test_bad_cron_time_leaves_the_hook_alone(monkeypatch, capsys):