OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

invalid ov.conf aborts boot with no remediation pointer, and auto-restart turns it into a silent crash loop

Open a692570 opened this issue 3 months ago • 2 comments

What happens

OpenViking rejects unknown top-level ov.conf fields with a ValueError and exits 1. Strict validation is the right behavior, and I know it was requested in #855.

The problem is the failure surface. On boot the operator gets one bare line on stderr:

Unknown config field 'claude_code' in OpenVikingConfig

That line omits which config file was read, what to run next, and where the supported fields are documented. Under a process manager with auto-restart (launchd KeepAlive, systemd Restart=always, Docker restart: always), exit 1 just means "start again". The server then crash-loops with no visible signal, because stderr goes to a log file that headless deployments do not watch.

openviking-server doctor can validate the config exactly the way boot does, so a pointer that would actually help already exists. The boot error never mentions it.

Minimal reproduction

Environment: OpenViking 0.4.12 server on macOS, managed by launchd with KeepAlive enabled. I verified the same code paths on main at commit c486088 (2026-09-01).

  1. Add a top-level claude_code section to ~/.openviking/ov.conf. Any unknown top-level key works.
  2. Start the server with auto-restart enabled.
  3. Observe: one Unknown config field ... line per boot attempt on stderr, exit 1, immediate restart, forever.

The claude_code choice is not invented. The bundled ov-memory-doctor skill lists claude_code, codex, and server.url as "plugin-only keys in ov.conf that make the server refuse to start" (examples/claude-code-memory-plugin/skills/ov-memory-doctor/SKILL.md:34, and the troubleshooting table below it). The shipped examples/ov.conf.example shows server, bot, and parsers as top-level sections (lines 2, 252, 272), so a reader who has never seen the allowlist reasonably concludes that tool sections live at the top level of ov.conf.

Evidence (production)

I run OpenViking headless on macOS under launchd. In August an ov.conf edit introduced a top-level claude_code section. The server exited on every boot and launchd restarted it continuously for 22 days before I traced the failure through stale memory captures.

The stderr log held that same single line 91,574 times, once per boot attempt. Nothing else in the output named a file or a next step. During those 22 days the server was down, so session capture, recall, and scheduled ingestion all failed against it.

Root cause on main (commit c486088)

  • openviking_cli/utils/config/config_utils.py:19-38 (raise_unknown_config_fields) builds the error from the field name and the model class name only. suggest_closest_field helps only on near-misses; a section like claude_code has no close match among the valid fields, so the message is bare.
  • openviking/server/config.py:426-464 (load_server_config) raises the parse ValueError without wrapping in the resolved config path. The same function's FileNotFoundError branch (lines 446-452) shows the pattern already exists in this codebase: it names both default paths, the OPENVIKING_CONFIG_FILE override, and a docs URL.
  • openviking/server/bootstrap.py:218-221 catches (FileNotFoundError, ValueError), prints str(e) to stderr, and calls sys.exit(1). That print is the entire operator-facing output for a bad config.
  • openviking_cli/utils/config/open_viking_config.py:455-458 is where the strictness lives: the top-level allowlist is the model fields plus server, bot, parsers, and everything else raises.
  • openviking_cli/doctor.py:110-127 already validates ov.conf through OpenVikingConfig.from_dict (the fix for #2373) and reports unknown fields with a remediation line. The boot path just never points at it.
  • docs/en/guides/03-deployment.md:109 recommends Restart=always for systemd deployments, with no note about validating the config first or about how a config error behaves under restart.

Proposed fix

Keep strict validation. Change only the boot failure output:

  1. In bootstrap.py:218-221, print the resolved config path next to the error (the resolve_config_path call sits a few lines above in the same try block), plus two lines: Run 'openviking-server doctor' to validate the config. and Supported fields: examples/ov.conf.example.
  2. Wrap the parse ValueError in load_server_config with the resolved path, the same way the FileNotFoundError branch already does.
  3. Optional: exit with 78 (EX_CONFIG from sysexits) instead of 1, so supervisors can distinguish config errors from crashes, for example OnFailure= in systemd instead of treating both cases as restartable crashes.

I run OpenViking in production and can test a patch against main within a day.

a692570 avatar Sep 01 '26 23:09 a692570

Issue Origin: Observed or reproduced in a real environment (production OpenViking 0.4.12 under launchd with KeepAlive; code paths re-verified against main at c486088 on 2026-09-01).

a692570 avatar Sep 01 '26 23:09 a692570

I'd like to work on this.

My plan is to keep the fix narrowly scoped to diagnostics only:

  • include the resolved ov.conf path when configuration parsing fails;
  • preserve the original parse error;
  • add an actionable hint to run openviking-server doctor;
  • point users to examples/ov.conf.example for supported fields;
  • add a focused regression test for the malformed-config error path.

jamespud avatar Sep 02 '26 10:09 jamespud