feat(config): add actionable startup diagnostics and WebUI recovery (#5110)

This commit is contained in:
chengyongru
2026-07-28 18:52:05 +08:00
committed by GitHub
parent 76ab04ac48
commit 0c6c0438d4
19 changed files with 1425 additions and 64 deletions
+17
View File
@@ -2,6 +2,7 @@ import json
import pytest
from nanobot.config.errors import ConfigLoadError
from nanobot.config.loader import (
_resolve_env_vars,
load_config,
@@ -66,6 +67,22 @@ class TestResolveConfig:
resolved = resolve_config_env_vars(raw)
assert resolved.providers.groq.api_key == "resolved-key"
def test_missing_env_var_reports_config_field(self, tmp_path, monkeypatch):
name = "NANOBOT_TEST_MISSING_PROVIDER_KEY"
monkeypatch.delenv(name, raising=False)
config_path = tmp_path / "config.json"
config = Config.model_validate(
{"providers": {"openrouter": {"apiKey": f"${{{name}}}"}}}
)
with pytest.raises(ConfigLoadError) as exc_info:
resolve_config_env_vars(config, config_path=config_path)
error = exc_info.value
assert error.kind == "missing_env"
assert "providers.openrouter.apiKey" in str(error)
assert name in str(error)
def test_save_preserves_templates(self, tmp_path, monkeypatch):
monkeypatch.setenv("MY_TOKEN", "real-token")
config_path = tmp_path / "config.json"