fix: 数据源审查小修(from_config 类型守卫/PROMPTS_KEYS 消重/契约措辞)
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -80,7 +80,13 @@ class PromptProvider:
|
||||
def from_config(cls, md: dict) -> "PromptProvider":
|
||||
"""快照 prompts 组 → PromptProvider。缺键/非字符串显性炸带键名
|
||||
(DB 快照坏数据不留到 build_system 才炸)。"""
|
||||
bad = [k for k in PROMPTS_KEYS if not isinstance((md or {}).get(k), str)]
|
||||
if not isinstance(md, dict):
|
||||
# 入口类型守卫(Task 6 的 PUT prompts 会接请求体): 字符串/
|
||||
# 列表进来给 ValueError,不让 .get 的 AttributeError 漏成 500
|
||||
raise ValueError(
|
||||
f"prompts 必须是 dict: {{{', '.join(PROMPTS_KEYS)}}}: "
|
||||
f"实际 {type(md).__name__}")
|
||||
bad = [k for k in PROMPTS_KEYS if not isinstance(md.get(k), str)]
|
||||
if bad:
|
||||
raise ValueError(f"prompts 配置缺少(或非字符串)键: {', '.join(bad)}")
|
||||
return cls(
|
||||
|
||||
Reference in New Issue
Block a user