Skip to content

DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.

fix(lightrag): reject unsupported settings versions without fallback

NoxsMedia71ade6b84fcf
diff --git a/deeptutor/services/config/runtime_settings.py b/deeptutor/services/config/runtime_settings.py
index 19ff72ebe..60e611d54 100644
--- a/deeptutor/services/config/runtime_settings.py
+++ b/deeptutor/services/config/runtime_settings.py
@@ -971,6 +971,10 @@ class RuntimeSettingsService:
def _normalize_lightrag(self, settings: dict[str, Any]) -> dict[str, Any]:
from .lightrag_roles import LightRagRoleModels
+ version = settings.get("version", 1)
+ if type(version) is not int or version not in {1, 2}:
+ raise ValueError("Unsupported LightRAG settings version.")
+
# Missing means a released, legacy setting. Never turn malformed new
# configuration back into a legacy model fallback.
role_models = settings.get("role_models")
diff --git a/tests/services/rag/test_lightrag_roles.py b/tests/services/rag/test_lightrag_roles.py
index bc5f16859..a1027b857 100644
--- a/tests/services/rag/test_lightrag_roles.py
+++ b/tests/services/rag/test_lightrag_roles.py
@@ -762,3 +762,16 @@ def test_fresh_defaults_do_not_enter_legacy_model_or_vision_fallback(role_enviro
role_environment["settings"] = legacy
# The compatibility path retains historical vision semantics.
assert policy.freeze_roles(choice(3)).vlm is not None
+
+
[email protected]("version", [3, "2", True])
+def test_invalid_settings_version_never_becomes_legacy_fallback(tmp_path, version):
+ from deeptutor.services.config.runtime_settings import RuntimeSettingsService
+
+ service = RuntimeSettingsService(tmp_path, process_env={})
+ path = service.path_for("lightrag")
+ path.write_text(json.dumps({"version": version}))
+ before = path.read_bytes()
+ with pytest.raises(ValueError, match="settings version"):
+ service.load_lightrag()
+ assert path.read_bytes() == before