CC Switch local proxy failed while handling Codex endpoint /responses. Provider:...

2026年08月25日 16:43 24.14 秒 success

错误信息

CC Switch local proxy failed while handling Codex endpoint /responses. Provider: DeepSeek; model: deepseek-v4-flash; upstream_status: HTTP 400; cause: Invalid schema for function 'codex_app__automation_update': schema must be a JSON Schema of 'type: "object"', got 'type: null'.

AI 解决方案

🔍 报错分析

1. 🌐 错误翻译


原文:CC Switch local proxy failed while handling Codex endpoint /responses. Provider: DeepSeek; model: deepseek-v4-flash; upstream_status: HTTP 400; cause: Invalid schema for function 'codex_app__automation_update': schema must be a JSON Schema of 'type: "object"', got 'type: null'.
译文:CC Switch 本地代理在处理 Codex 端点 /responses 时失败。提供商:DeepSeek;模型:deepseek-v4-flash;上游状态:HTTP 400;原因:函数 'codex_app__automation_update' 的 schema 无效:schema 必须是 'type: "object"' 的 JSON Schema,但得到了 'type: null'。

2. 🎯 原因分析


  • 根本原因:函数 codex_app__automation_update 的 JSON Schema 定义中,type 字段被设置为 null,而接口要求必须是 "object"

  • 错误位置:问题出在函数调用的参数 schema 定义上,具体是在自动化更新相关的函数配置中。

  • 上下文影响:该错误导致上游服务(DeepSeek 模型)返回 HTTP 400 状态,代理请求失败,无法正确处理 /responses 端点的调用。
  • 3. 💡 解决方案


    检查函数 codex_app__automation_update 的 schema 定义,确保 type 字段明确设置为 "object",并修复可能的 null 值问题。以下是修复后的示例:

    {
      "type": "object",
      "properties": {
        // 其他参数定义...
      },
      "required": ["必要参数名"]
    }
    

    若你正在通过代码动态生成 schema,修复代码中的 schema 构造逻辑,例如(以JavaScript为例):

    // 修复前可能的错误构造方式
    const invalidSchema = {
      type: null, // 错误:type 不能为 null
      properties: { /* ... */ }
    };
    
    // 修复后
    const validSchema = {
      type: "object", // 正确:明确设置为 "object"
      properties: { /* ... */ }
    };
    

    4. 🛡️ 预防措施


  • schema 强制校验:在构造 JSON Schema 时,严格校验关键字段(如 type)的类型和值,禁止传入 null、undefined 等非法值,推荐使用 TypeScript 或运行时校验工具(如 ajv)进行强类型约束。

  • 开发调试工具:使用 JSON Schema 在线校验工具(如 [JSON Schema Lint](https://jsonschemalint.com/))在开发阶段验证 schema 合法性,或集成单元测试覆盖 schema 构造逻辑,提前发现参数类型异常。