Type validation failed: Value: {"type":"content_block_start","index":0,"content_...
错误信息
Opencode failed to send message with error: Type validation failed: Value: {"type":"content_block_start","index":0,"content_block":{"type":"tool_use","input":{}}}. Error message: [ { "expected": "string", "code": "invalid_type", "path": [ "content_block", "id" ], "message": "Invalid input: expected string, received undefined" }, { "expected": "string", "code": "invalid_type", "path": [ "content_block", "name" ], "message": "Invalid input: expected string, received undefined" } ]
AI 解决方案
##报错分析报告
1.错误翻译
原文:Invalid input: expected string, received undefined
译文:无效输入:期望字符串类型,但收到undefined
2.原因分析
content_block对象缺少必需的id和name字符串属性,触发类型验证失败 Value中content_block对象({"type":"tool_use","input":{}})未包含id/name字段3.解决方案
// 修复后的Value结构(补充id和name字符串属性)
{
"type": "content_block_start",
"index": 0,
"content_block": {
"type": "tool_use",
"id": "tool_123", // 新增:字符串类型ID
"name": "example_tool", // 新增:字符串类型名称
"input": {}
}
}
4. 预防措施
---
请确认修复后是否解决报错,若有其他错误信息可继续提供。