Skip to content

fix: Claude Desktop 官方供应商添加报错 #3402#3405

Merged
farion1231 merged 3 commits into
farion1231:mainfrom
Eunknight:fix/desktop-official-provider-validation
May 31, 2026
Merged

fix: Claude Desktop 官方供应商添加报错 #3402#3405
farion1231 merged 3 commits into
farion1231:mainfrom
Eunknight:fix/desktop-official-provider-validation

Conversation

@Eunknight

@Eunknight Eunknight commented May 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • 修复添加 Claude Desktop 官方供应商时报错 "缺少 ANTHROPIC_BASE_URL" (Claude desktop 添加官方默认配置 Claude Code Official 报错 #3402)
  • 根因validate_direct_providervalidate_proxy_providervalidate_providerapply_provider_to_paths 四个函数仅通过 is_official_provider()(基于 provider id/name)判断官方供应商,但新添加的官方供应商尚未分配固定 id,导致校验失败
  • 前端:为 claude-desktop 官方供应商分配固定 id claude-desktop-official,与后端 seed 和 is_official_provider 校验一致

Changes

Rust 后端 (claude_desktop_config.rs)

  • 4 处增加 provider.category.as_deref() == Some("official") 兜底判断

前端 (mutations.ts)

  • 添加 claude-desktop + official category 时使用固定 id claude-desktop-official

Test plan

  • 打开 Claude Desktop 供应商列表
  • 选择 "Claude Desktop Official" 预设
  • 点击"添加",应成功添加不再报错
  • 验证其他非官方供应商添加/编辑不受影响

Closes #3402

根因:前端 mutation 为 claude-desktop 生成随机 UUID 作为 provider id,
后端 is_official_provider 通过 id 匹配跳过校验,随机 UUID 不匹配导致
走入普通 direct 模式校验并要求 ANTHROPIC_BASE_URL。

修复:
- 前端:claude-desktop + category=official 时使用固定 id "claude-desktop-official"
- 后端:validate_provider / validate_direct_provider / validate_proxy_provider /
  apply_provider_to_paths 增加 category=="official" 兜底检查

Fixes farion1231#3402
@farion1231

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ec3d4f1327

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src-tauri/src/claude_desktop_config.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2aaf87d9b1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/lib/query/mutations.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 134c055da8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src-tauri/src/commands/provider.rs

@farion1231 farion1231 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢您的贡献!

@farion1231
farion1231 merged commit 0960fd7 into farion1231:main May 31, 2026
3 checks passed
gfunc pushed a commit to gfunc/cc-switch that referenced this pull request Jun 19, 2026
* fix: Claude Desktop 官方供应商添加时缺少 ANTHROPIC_BASE_URL 报错

根因:前端 mutation 为 claude-desktop 生成随机 UUID 作为 provider id,
后端 is_official_provider 通过 id 匹配跳过校验,随机 UUID 不匹配导致
走入普通 direct 模式校验并要求 ANTHROPIC_BASE_URL。

修复:
- 前端:claude-desktop + category=official 时使用固定 id "claude-desktop-official"
- 后端:validate_provider / validate_direct_provider / validate_proxy_provider /
  apply_provider_to_paths 增加 category=="official" 兜底检查

Fixes farion1231#3402

* fix: restrict Claude Desktop official provider detection

* fix: add Claude Desktop official provider via seed

---------

Co-authored-by: 金恩光 <[email protected]>
Co-authored-by: Jason <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Claude desktop 添加官方默认配置 Claude Code Official 报错

2 participants