Skip to content

Plan, apply and roll back changes to a production ontology, with a blast radius report and a proof an auditor can re-check.

fix(python): report non-object checker JSON as unchecked

Rudy Celekli609e6d8782c0
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6646495d..35636e2e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,8 @@ All notable changes to Open Ontologies are documented here.
### Fixed
+- Report non-object JSON from a configured Python certificate checker as unchecked instead of raising an attribute error.
+
- Keep the last active ontology intact when parsing a replacement source, cache, or refresh fails; publish successful replacements in one graph transaction.
- Bound wildcard repository filtering to pattern/filename pairs so repeated stars cannot stall `onto_repo_list`.
- Sanitize quotes and ASCII control bytes in mapped IRI components so valid structured data does not fail RDF ingestion.
diff --git a/python/src/open_ontologies_lite/horn/certify.py b/python/src/open_ontologies_lite/horn/certify.py
index 2f93b7f9..345f79b1 100644
--- a/python/src/open_ontologies_lite/horn/certify.py
+++ b/python/src/open_ontologies_lite/horn/certify.py
@@ -267,6 +267,15 @@ def check_horn(
warning=f"the certificate was written and NOT checked. {_UNPROVED}",
)
+ if not isinstance(payload, dict):
+ return _unchecked(
+ "unchecked_error",
+ certificate_dir,
+ name,
+ error=f"{binary} exited {proc.returncode} and its JSON output is not an object",
+ warning=f"the certificate was written and NOT checked. {_UNPROVED}",
+ )
+
if proc.returncode == 1 and payload.get("ok") is False:
return {
"status": "rejected",
diff --git a/python/tests/test_horn_checker_json.py b/python/tests/test_horn_checker_json.py
new file mode 100644
index 00000000..7399106f
--- /dev/null
+++ b/python/tests/test_horn_checker_json.py
@@ -0,0 +1,48 @@
+"""Checker transport fixtures exercise subprocess output, not Lean proofs."""
+
+import json
+import sys
+
+import pytest
+
+from open_ontologies_lite.horn.certify import check_horn
+
+
+def _checker_response(tmp_path, monkeypatch, output, code=0):
+ # The configured Python executable runs our task-owned `check` script.
+ # This uses the real subprocess transport without requiring a Lean binary.
+ (tmp_path / "check").write_text(
+ "import sys\nsys.stdout.write(" + repr(output) + ")\nraise SystemExit(" + str(code) + ")\n",
+ encoding="utf-8",
+ )
+ monkeypatch.chdir(tmp_path)
+ return check_horn(tmp_path, checker=sys.executable)
+
+
[email protected]("payload", [[], None, True, 7, "unexpected"], ids=["array", "null", "boolean", "number", "string"])
[email protected]("code", [0, 1], ids=["exit-zero", "exit-one"])
+def test_non_object_checker_json_is_unchecked(tmp_path, monkeypatch, payload, code):
+ report = _checker_response(tmp_path, monkeypatch, json.dumps(payload), code)
+ assert report["status"] == "unchecked_error"
+ assert report["checked"] is False
+ assert report["verdict"] is None
+ assert report["pronounced_by"] is None
+ assert "JSON output is not an object" in report["error"]
+
+
+ "output,code,status,checked",
+ [
+ ("not JSON", 0, "unchecked_error", False),
+ ('{"ok": true}', 0, "unchecked_error", False),
+ ('{"ok": false}', 1, "rejected", True),
+ ('{"ok": false}', 3, "unchecked_error", False),
+ ("", 2, "unreadable", False),
+ ],
+ ids=["malformed-json", "missing-fields", "rejection", "unexpected-exit", "unreadable"],
+)
+def test_existing_checker_outcomes_are_preserved(tmp_path, monkeypatch, output, code, status, checked):
+ report = _checker_response(tmp_path, monkeypatch, output, code)
+ assert report["status"] == status
+ assert report["checked"] is checked
+ assert report["verdict"] is None