Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
fix(server): improve invalid config diagnostics (#4596)
spud85b4923d06ef
diff --git a/openviking/server/bootstrap.py b/openviking/server/bootstrap.pyindex 01c991f7d..61d16f2e9 100644--- a/openviking/server/bootstrap.py+++ b/openviking/server/bootstrap.py@@ -216,7 +216,19 @@ def main():config = load_server_config(args.config)OpenVikingConfigSingleton.initialize(config_path=args.config)except (FileNotFoundError, ValueError) as e:- print(e, file=sys.stderr)+ if isinstance(e, ValueError):+ print(+ f"Failed to load OpenViking server configuration from {resolved_config_path}:\n{e}",+ file=sys.stderr,+ )+ print(+ "\nValidate the configuration with:\n"+ " openviking-server doctor\n\n"+ "See examples/ov.conf.example for supported fields.",+ file=sys.stderr,+ )+ else:+ print(e, file=sys.stderr)sys.exit(1)# Configure logging early so that all subsequent steps have proper loggingdiff --git a/openviking/server/config.py b/openviking/server/config.pyindex 211780b8e..0703ed3c7 100644--- a/openviking/server/config.py+++ b/openviking/server/config.py@@ -459,7 +459,7 @@ def load_server_config(config_path: Optional[str] = None) -> ServerConfig:if server_data is None:server_data = {}if not isinstance(server_data, dict):- raise ValueError("Invalid server config: 'server' section must be an object")+ raise ValueError(f"Invalid server config in {path}: 'server' section must be an object")# Convert auth_mode string — built-in enums are converted to their string# value; custom modes are kept as-is for plugin extensibility.diff --git a/tests/server/test_bootstrap.py b/tests/server/test_bootstrap.pyindex 64a7f0198..65f68120f 100644--- a/tests/server/test_bootstrap.py+++ b/tests/server/test_bootstrap.py@@ -4,8 +4,11 @@from __future__ import annotationsimport os+from pathlib import Pathfrom types import SimpleNamespace+import pytest+import openviking.server.app as app_moduleimport openviking.server.bootstrap as bootstrapfrom openviking.server.config import ServerConfig@@ -219,6 +222,48 @@ def test_bot_alias_propagates_resolved_config_to_workers(monkeypatch):assert os.environ[app_module.WORKER_BOT_API_URL_ENV] == "http://127.0.0.1:19000"+def test_main_prints_config_diagnostics_on_validation_error(monkeypatch, capsys):+ """An unknown top-level config field must exit 1 with actionable diagnostics."""+ config = ServerConfig(host="127.0.0.1", port=1933)++ monkeypatch.setattr(bootstrap, "resolve_config_path", lambda *a, **k: Path("/tmp/ov.conf"))+ monkeypatch.setattr(bootstrap, "load_server_config", lambda *a, **k: config)++ def failing_initialize(cls, config_path):+ raise ValueError("Unknown config field 'claude_code' in OpenVikingConfig")++ monkeypatch.setattr(+ OpenVikingConfigSingleton,+ "initialize",+ classmethod(failing_initialize),+ )+ monkeypatch.setattr(+ bootstrap.argparse.ArgumentParser,+ "parse_args",+ lambda self: SimpleNamespace(+ host=None,+ port=None,+ config="/tmp/ov.conf",+ workers=None,+ bot=False,+ with_bot=False,+ bot_url="http://localhost:18790",+ enable_bot_logging=None,+ bot_log_dir="/tmp/bot-logs",+ ),+ )++ with pytest.raises(SystemExit) as exc:+ bootstrap.main()++ assert exc.value.code == 1+ err = capsys.readouterr().err+ assert "/tmp/ov.conf" in err+ assert "Unknown config field 'claude_code'" in err+ assert "openviking-server doctor" in err+ assert "examples/ov.conf.example" in err++def test_worker_factory_replays_bot_overrides(monkeypatch):config = ServerConfig(with_bot=False, bot_api_url="http://from-config")captured = {}