快速结论:该报错通常出现在 n8n 使用 Mistral(或兼容 OpenAI schema 的自定义 provider)时,模型返回的流式 delta.content 是数组(thinking block)而不是字符串,导致节点侧 schema 校验失败。优先排查模型是否输出了 reasoning/thinking 内容,以及当前 n8n 版本是否已包含对应修复。
适用环境:Issue 中已确认的环境为 n8n 2.36.8、Docker(self-hosted)、Node.js 24.18.1、PostgreSQL、execution mode 为 main(default);操作系统为 Docker。
最快修复方案:暂无确认的一步修复方案。Issue 中提到的 PR https://github.com/n8n-io/n8n/pull/37875 声称已修复,但后续评论指出该 MR 未合并且问题仍存在,因此不能视为已验证的修复。
注意事项:切换到 OpenRouter 可作为临时规避(它会把 thinking block 剥离,schema 能通过),但这并非直接修复 Mistral 直连场景;在 n8n 节点支持关闭 reasoning 输出之前,直连 Mistral 仍可能触发同类校验错误。
问题场景
用户在 n8n 的 AI 相关节点中配置 Mistral 作为 provider,使用较大、需要更多 thinking 的 Prompt 时,聊天流程不断抛出错误。同一 Prompt 走 OpenRouter 则正常,说明问题与 Mistral 返回的内容结构有关,而非 Prompt 本身。
报错原文
Type validation failed: Value: {"id":"0a2455cdc0d84c2c9b9e7cb1013436e9","object":"chat.completion.chunk","created":1788002702,"model":"zai-glm-5-2","choices":[{"index":0,"delta":{"index":0,"content":[{"type":"thinking","thinking":[{"type":"text","text":" existing Telegram credentials."}],"closed":true}]},"finish_reason":null,"logprobs":null}]}. Error message: [ { "code": "invalid_union", "errors": [ [ { "expected": "string", "code": "invalid_type", "path": [ "choices", 0, "delta", "content" ], "message": "Invalid input: expected string, received array" } ], [ { "expected": "object", "code": "invalid_type", "path": [ "error" ], "message": "Invalid input: expected object, received undefined" } ] ], "path": [], "message": "Invalid input" } ]
原因分析
最可能的原因是 Mistral 在流式响应中把 choices[0].delta.content 返回为 thinking block 数组(type: "thinking"),而 n8n 2.36.8 中 OpenAI 兼容节点按标准 OpenAI schema 校验该字段,期望它是字符串。校验以 union 形式进行:要么 delta.content 是 string,要么返回 error 对象;两者都不满足时就报 invalid_union。Issue 评论中也指出同一原因:Mistral 把 content 作为 thinking block 数组流式返回,n8n 的 schema 只接受字符串。
环境排查
- 确认 n8n 版本,Issue 中为 2.36.8;该版本被指出存在此 schema 校验缺陷。
- 确认运行方式为 Docker self-hosted,Node.js 24.18.1。
- 确认数据库与执行模式(PostgreSQL、execution mode main/default),用于排除执行链路上的其他干扰。
- 确认 AI 节点使用的是 Mistral 直连,还是 OpenRouter 等中转;OpenRouter 场景在 Issue 中表现正常。
- 确认所调用模型是否会产生 reasoning/thinking 输出;示例响应中出现了
type: "thinking"结构。
解决步骤
- 如果只是想让工作流尽快恢复,可优先尝试将 AI 节点的 provider 从 Mistral 直连切换为 OpenRouter,Issue 中确认该路径可正常返回。
- 如果必须使用 Mistral 直连,检查当前使用的 AI 节点是否提供关闭 reasoning / thinking 输出的选项;如可关闭,先关闭后重试,避免
delta.content以数组形式返回。 - 关注 Issue 中提到的修复 PR(https://github.com/n8n-io/n8n/pull/37875)的合并状态;在评论中指出该 MR 未合并、问题仍复现,因此升级前需确认修复是否真正进入发布版本。
- 如需临时跟踪,可参考内部 Linear 票据 GHC-9371 的进展,但该票据仅限内部使用。
验证方法
用相同的大 Prompt 重新运行出错的 n8n AI 节点:若不再抛出 Type validation failed / invalid_union,且聊天输出正常返回,说明问题已被绕开或修复。若切换 provider 后正常、切回 Mistral 又复现,则可确认问题仍与 Mistral 的 thinking block 返回结构相关。
参考来源
AI 工具推荐
想把多个 AI 模型放在一个入口?
GamsGo AI 集成 ChatGPT、DeepSeek、Gemini、Claude、Midjourney、Veo 等常用模型,适合写作、绘图、视频和日常 AI 工作流。
推广链接:通过此链接购买,我可能获得佣金,不影响你的价格。
这个方案解决了吗?
可以继续搜索完整报错,或查看同一工具的其他排查指南。


![PermissionError: [Errno 13] error while attempting to bind on address ('127.0.0.1', 8188)](https://www.chat-gpts.plus/wp-content/uploads/2026/10/3345-3eacb91d-768x403.jpg)