xiaozhi-esp32-server/main/xiaozhi-server
Allen 579538478b fix(util): check_model_key 遇到空 api_key 不再抛 TypeError
现象:provider 构造期报
    TypeError: argument of type 'NoneType' is not iterable
而且栈顶落在 core/utils/util.py 的 check_model_key,看不出是哪个模块的
key 没配。智控台下发的配置里未必带 api_key 字段(本地 LLM 场景也常把
它留空),HA 插件配置没填 api_key 时同样中招:hass_state 和
hass_play_music 都调 initialize_hass_handler,整个插件初始化被打断。

原因:check_model_key 直接写 ``"你" in modelKey``,modelKey 为 None 时
这行就炸了;modelKey 为空串时则静默返回 None,等于没检查。

改法:先把 None / 空串当成「未设置」处理,返回提示文案而不是抛异常。
    if not modelKey:
        return f"配置错误: {modelType} 的 API key 未设置"
出厂占位符的分支保持原样,提示文案里仍带当前值,方便用户对照改。

测试:
- 新增 tests/core/utils/test_check_model_key.py:缺 key / 占位符 / 真 key
  三种情况的契约
- tests/plugins_func/test_hass_init.py 补一条端到端:插件配置里没有
  api_key 时 initialize_hass_handler 不再崩
- 全量 pytest tests/ -q 无新增失败

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-11-07 22:33:44 +08:00
..
config Bump to 0.9.8 (#3469) 2026-10-23 18:54:05 +08:00
core fix(util): check_model_key 遇到空 api_key 不再抛 TypeError 2026-11-07 22:33:44 +08:00
models 重新划分目录 (#214) 2025-03-05 23:13:24 +08:00
music 重新划分目录 (#214) 2025-03-05 23:13:24 +08:00
performance_tester 性能测试跳过未配置的Linkerai语音合成 (#3510) 2026-10-27 15:35:38 +08:00
plugins_func fix: 修复ha读取异常 2026-11-05 15:36:04 +08:00
tests fix(util): check_model_key 遇到空 api_key 不再抛 TypeError 2026-11-07 22:33:44 +08:00
agent-base-prompt.txt fix: 2026-07-08 16:14:10 +08:00
app.py hello 握手并发与缓存 2026-10-14 23:05:12 +08:00
config.yaml feat(web_search): 新增Outcrawl搜索源 (#3538) 2026-11-04 10:22:41 +08:00
config_from_api.yaml fix:修复全模块时缺少prompt_template配置的问题 2025-10-31 20:36:55 +08:00
docker-compose.yml fix: 设备最后连接时间返回 UTC 时间戳,修复时区显示问题 2026-05-27 17:35:10 +08:00
docker-compose_all.yml update:增加ragflow部署教程 2025-11-11 18:47:25 +08:00
mcp_server_settings.json update:服务端MCP新增支持Streamable HTTP传输协议 2025-10-29 23:14:42 +08:00
performance_tester.py 补齐五份 README 的供应器清单和音频测试工具用法 (#3491) 2026-10-26 22:26:15 +08:00
pyproject.toml 配 pytest 与 conftest,修模块路径 2026-09-02 22:24:35 +08:00
requirements.txt Merge branch 'perf/hello-handshake-fast' of https://github.com/xinnan-tech/xiaozhi-esp32-server into perf/hello-handshake-fast 2026-10-26 17:04:54 +08:00