From 67608c21b0103adb37f3d994b1b6d756e63f7090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9E=AC=ED=98=84?= <231584193+kimdzhekhon@users.noreply.github.com> Date: Sun, 19 Jul 2026 22:55:14 +0900 Subject: [PATCH] test(serve): pin generic ValueError message against clause-order regression Per review on #2017 (thanks @HerenderKumar): add a guard asserting a non-decode ValueError (e.g. a non-.json path) still prints the plain "must be a .json file" message, not the corrupted-graph hint. Locks in the except-clause order from the parent fix so a future refactor can't silently collapse the two branches back together. --- tests/test_serve.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/test_serve.py b/tests/test_serve.py index bf0b4f4..3baa8d5 100644 --- a/tests/test_serve.py +++ b/tests/test_serve.py @@ -612,6 +612,19 @@ def test_load_graph_corrupted_json_prints_recovery_message(tmp_path, capsys): assert "Re-run /graphify to rebuild" in err +def test_load_graph_generic_value_error_message_unchanged(tmp_path, capsys): + """A non-decode ValueError (e.g. a non-.json path) must still print the + generic error, not the corrupted-graph hint — pins the except-clause + order from #2005 so a future refactor can't collapse them back.""" + p = tmp_path / "graph.txt" + p.write_text("not a graph") + with pytest.raises(SystemExit): + _load_graph(str(p)) + err = capsys.readouterr().err + assert "must be a .json file" in err + assert "corrupted" not in err + + def test_load_graph_rejects_oversized_file(monkeypatch, tmp_path, capsys): # #F4: oversized graph.json must fail fast (SystemExit) with a clear error. G = _make_graph()