Skip to content

[Bug] capabilities/default.json 中的 http://[::1]:* 导致 HTTP scope 反序列化失败,「优化提示词」等功能不可用 (v5.29.1) #187

Description

@Wattls

环境

  • Any Code 版本:v5.29.1(当前最新 release)
  • 操作系统:Windows 11
  • 触发功能:优化提示词(提示词增强 / Prompt Enhancement),Provider 选择 DeepSeek

问题描述

使用「优化提示词」功能时立即报错,请求根本没有发送到 Provider。无论选哪个 Provider(DeepSeek / OpenAI / 通义 / Gemini 等)都一样。

报错信息:

❌ deepseek: Error during deserialization of the "scope" parameter: `http://[::1]:*` is not a valid URL pattern. Tokenizer error: The name provided is invalid; it must have a length of at least 1 character (starting from the first character).

复现步骤

  1. 在「提示词增强」中配置任意 Provider(如 DeepSeek,填入合法 endpoint 与 key)
  2. 在输入框输入一段提示词,点击「优化提示词」
  3. 立即出现上述报错(请求未发出)

根因分析

报错来自 Tauri HTTP 插件的 scope 校验,与 Provider 配置无关。

src-tauri/capabilities/default.jsonhttp:default 能力里,allow 列表包含一条非法的 IPv6 回环地址:

{
  "identifier": "http:default",
  "allow": [
    { "url": "https://*" },
    { "url": "https://*:*" },
    { "url": "http://127.0.0.1:*" },
    { "url": "http://localhost:*" },
    { "url": "http://[::1]:*" }
  ]
}

前端通过 @tauri-apps/plugin-http 发请求时,Tauri 会把每条 allow[].url 编译成 URLPattern 来匹配。http://[::1]:* 无法解析:URLPattern 语法中 : 用于声明命名分组,IPv6 字面量里的 :: 被当成「长度为 0 的分组名」,于是 tokenizer 报错,整个 scope 反序列化失败 → 请求被拦截。

所以:

  • 不是 DeepSeek 的 key/endpoint 问题(请求根本没发出去);
  • 所有走 Tauri HTTP 插件的 Provider 都会触发,不止 DeepSeek;
  • 凡是依赖该 HTTP 插件 scope 的功能都会受影响。

建议修复

删除这条 scope 即可(http://127.0.0.1:*http://localhost:* 已覆盖本机回环):

     { "url": "http://127.0.0.1:*" },
-    { "url": "http://localhost:*" },
-    { "url": "http://[::1]:*" }
+    { "url": "http://localhost:*" }

若确有 IPv6 回环需求:URLPattern 无法用 http://[::1]:* 表达,需改用其它写法或直接去掉。

补充

  • 当前 main 分支该文件仍包含这一行(最近改动 2026-05-17),即最新 v5.29.1 也未修复。
  • 相关代码:src/lib/promptEnhancementService.ts(提示词增强请求)、src-tauri/capabilities/default.json(scope 定义)。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions