Skip to content

正常对话时报 403 错误:Error invoking remote method 'codesign:v1:generate' #124

Closed

Description

@Sun-sunshine06

问题描述

测试连接时正常,但进行正常对话时弹出错误:

Error invoking remote method 'codesign:v1:generate': CodesignError: 403 Your request was blocked.

复现步骤

  1. 在设置中测试 API 连接 → 正常通过
  2. 在对话界面发送消息 → 报 403 错误

Activity

  1. Sun-sunshine06 commented on Apr 22, 2026

    @Sun-sunshine06
    CollaboratorAuthor

    正在修复此问题。测试连接和实际调用的请求方式可能存在差异(如 model 参数、请求头、endpoint 不同),导致 403 策略拦截。

  2. github-actions commented on Apr 22, 2026

    @github-actions
    Contributor

    感谢反馈,复现描述很清楚。

    从当前代码看,这个现象是可能出现的:“测试连接”与“正常对话生成”走的是不同请求路径。

    • 设置页“测试连接”只探测 provider 的 /models 可达性与鉴权。
    • 聊天对话会走 codesign:v1:generate,再进入真实的生成请求(模型推理调用)。

    所以会出现“测试连接通过,但生成时报 403(Your request was blocked)”的情况:/models 可用不代表生成端点一定放行。

    另外,当前诊断里会把 403 和 401 归到同一类(密钥/权限问题),因此提示可能偏泛化。

    Relevant code:

    • apps/desktop/src/renderer/src/components/Settings.tsx:286 — 设置页“测试连接”调用 connection.testProvider(...)
    • apps/desktop/src/main/connection-ipc.ts:410 — runProviderTest 仅对 /models 做 GET 探测
    • apps/desktop/src/main/connection-ipc.ts:426 — 非 2xx 时按 HTTP 状态返回连接测试错误
    • apps/desktop/src/main/index.ts:448 — 对话生成走 codesign:v1:generate
    • apps/desktop/src/main/index.ts:581 — 生成调用 runGenerate(...)(真实模型请求)
    • apps/desktop/src/main/connection-ipc.ts:205 — 403 被归类为 401 类别
    • packages/shared/src/diagnostics.ts:61 — 诊断里 401/403 同归 keyInvalid
    • README.md:119 — 当前发布仍是 v0.1.x 早期阶段

    Need more info:

    • 你当前“激活中的 provider / model / baseUrl”分别是什么?
    • 是否使用了中转网关或自定义 baseUrl(以及是否配置了额外请求头)?
    • 请在 Settings → Storage 导出 diagnostics zip,并附上。
    • 请贴一段 main.log 里对应 generate.fail 的日志(包含 provider、modelId、baseUrl、message)。

    open-codesign Bot

  3. Sun-sunshine06 commented on Apr 22, 2026

    @Sun-sunshine06
    CollaboratorAuthor

    补一条同类现场证据,和本 issue 高度一致:

    • 现象:生成阶段报错,弹窗内容为
    Error invoking remote method 'codesign:v1:generate': CodesignError: 403 Your request was blocked.
    
    • 用户补充:无论是 codex 还是 claude 都不行,是 cpa 反代的
    • 截图显示:UI 仍然只是通用的“生成失败 / 生成过程中出错了”,没有给出更可操作的代理/上游拦截解释

    这条证据进一步支持当前判断:

    • 测试连接可通过,不代表真实生成请求会通过
    • 在反代 / 中转 / 自定义 provider 场景下,生成请求路径更容易被上游策略拦截
    • 问题并不局限于单一模型,至少用户反馈里 codex 和 claude 两条链路都可能触发同类 403 blocked

    建议把这类 case 一并纳入该问题,而不是按单个模型拆散处理。若后续需要,可再补 diagnostics zip / main.log 佐证。

  4. Sun-sunshine06 commented on Apr 22, 2026

    @Sun-sunshine06
    CollaboratorAuthor

    Another potentially related signal: see #136.

    In at least one user screenshot, the top bar shows the active model as opus-4-7, while the currently active provider card in Settings shows claude-3-5-haiku-20241022 and is still marked 当前.

    That suggests the UI may be exposing two different model states at once (top-bar active vs provider-card default/resolved state). If true, this could make 403 debugging much harder because the user may think the generate request is using one model while the app internally resolves another.

  5. added
    bugSomething isn't working
    area:providerspackages/providers (pi-ai adapter, model calls)
    needs-reproNeeds reproduction steps from reporter
    on Apr 22, 2026
  6. hqhq1025 commented on Apr 22, 2026

    @hqhq1025
    Collaborator

    @Sun-sunshine06 同步一下进度 —— 你 4/22 02:51 提到正在修复,请问目前进度如何?

    我这边正在并行做一个更通用的修复 PR(暂编号 #130 范围),把生成失败路径接到现有的 diagnose() hypothesis 系统,覆盖范围包括:

    如果你那边的修复方向不同/已经动手,麻烦贴一下 PR 链接或当前思路,避免重复工作。如果还没起手,我这个 PR 落地后会顺带 close 本 issue,你来 review 即可。

    cc @hqhq1025

  7. Sun-sunshine06 commented on Apr 22, 2026

    @Sun-sunshine06
    CollaboratorAuthor

    明白了!我这边只是做了问题整理和分析,还没有实际动手改代码。这个问题你已经分析得很清楚了,尽管放开手去改,我来帮你 review 合并 👍

  8. added
    bot-rerunTemporary label to rerun automation
    and removed
    bot-rerunTemporary label to rerun automation
    on May 1, 2026
  9. github-actions commented on May 1, 2026

    @github-actions
    Contributor

    感谢提交这个详细的报告。

    从已有讨论看,问题已经定位:测试连接(connection.testProvider)仅探测 /models 端点,而实际对话生成走 codesign:v1:generate → runGenerate 会触发真实的模型推理请求,两个路径可能被上游网关/反代区别对待,因此出现“测试通过但生成 403”的现象。

    当前代码中 403 被归为 keyInvalid 类别(packages/shared/src/diagnostics.ts:61),导致诊断提示不够精确。团队正在推进修复(如 PR #130 范围),会将 WAF/网关拦截等场景分离出独立的诊断提示。

    需要的补充信息(如果尚未提供):

    • 请导出 Settings → Storage → Diagnostics zip 并贴到这里
    • 你使用的具体 provider / model / baseUrl 是什么?是否使用了自定义中转或反代?
    • 如果可以,请贴一段 main.log 中对应 generate.fail 的完整日志

    这些数据能帮助验证修复逻辑的覆盖范围。


    Open-CoDesign Bot

  10. added a commit that references this issue on May 3, 2026
    418e5a8
  11. Sun-sunshine06 commented on May 3, 2026

    @Sun-sunshine06
    CollaboratorAuthor

    已在 PR #297 中修复并合并到 main。

    这次把生成请求返回的 403 Your request was blocked 识别为网关 / 反代 / WAF 拦截诊断,避免误提示为 API key 无效;普通 403 仍保留原有鉴权诊断。验证包含 targeted Biome、shared diagnostics 单测、desktop store 单测、desktop typecheck、全仓 typecheck 和 desktop 测试。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:providerspackages/providers (pi-ai adapter, model calls)bugSomething isn't workingneeds-reproNeeds reproduction steps from reporter

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions