Fail fast on invalid config files

This commit is contained in:
chengyongru
2026-06-10 18:09:36 +08:00
committed by Xubin Ren
parent 5d7f2e60c2
commit aee656eb9f
2 changed files with 31 additions and 3 deletions
+1 -3
View File
@@ -7,7 +7,6 @@ from pathlib import Path
from typing import Any
import pydantic
from loguru import logger
from pydantic import BaseModel
from nanobot.config.schema import Config, _resolve_tool_config_refs
@@ -55,8 +54,7 @@ def load_config(config_path: Path | None = None) -> Config:
data = _migrate_config(data)
config = Config.model_validate(data)
except (json.JSONDecodeError, ValueError, pydantic.ValidationError) as e:
logger.warning("Failed to load config from {}: {}", path, e)
logger.warning("Using default configuration.")
raise ValueError(f"Failed to load config from {path}: {e}") from e
_apply_ssrf_whitelist(config)
return config