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.
This commit is contained in:
김재현
2026-07-20 15:02:54 +01:00
committed by safishamsi
parent b890ca6590
commit 67608c21b0
+13
View File
@@ -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()