Skip to content

fix: 将明确的上游 blocked 类 LLM 测试失败从网络异常中拆分出来,展示为请求被服务商或网关拦截 (#1223) - #1224

Closed
ZhuLinsen wants to merge 5 commits into
mainfrom
autocode/issue-1223-bug-llm-your-request-was-blocked
Closed

fix: 将明确的上游 blocked 类 LLM 测试失败从网络异常中拆分出来,展示为请求被服务商或网关拦截 (#1223)#1224
ZhuLinsen wants to merge 5 commits into
mainfrom
autocode/issue-1223-bug-llm-your-request-was-blocked

Conversation

@ZhuLinsen

@ZhuLinsen ZhuLinsen commented May 7, 2026

Copy link
Copy Markdown
Owner

PR Type

  • fix
  • feat
  • refactor
  • docs
  • chore
  • test

Background And Problem

Scope Of Change

  • apps/dsa-web/src/components/settings/LLMChannelEditor.tsx
  • apps/dsa-web/src/components/settings/__tests__/LLMChannelEditor.test.tsx
  • docs/CHANGELOG.md
  • docs/LLM_CONFIG_GUIDE.md
  • docs/LLM_CONFIG_GUIDE_EN.md
  • src/services/system_config_service.py
  • tests/test_system_config_service.py

Documentation And Changelog

  • 已同步更新文档/变更记录:docs/CHANGELOG.md, docs/LLM_CONFIG_GUIDE.md, docs/LLM_CONFIG_GUIDE_EN.md

Issue Link

Closes #1223

Verification Commands And Results

./scripts/ci_gate.sh flake8
./scripts/ci_gate.sh offline-tests

关键输出/结论 / Key output & conclusion:

  • lint:PASS, test:PASS

Compatibility And Risk

  • Medium:涉及 apps/dsa-web/src/components/settings/LLMChannelEditor.tsx, apps/dsa-web/src/components/settings/__tests__/LLMChannelEditor.test.tsx, docs/CHANGELOG.md, docs/LLM_CONFIG_GUIDE.md, docs/LLM_CONFIG_GUIDE_EN.md, src/services/system_config_service.py,建议按文件范围复核。
  • 前提假设:
    • 现有 LLM 渠道测试结果已通过 error_code 和 details.reason 传递给前端,可通过新增分类值做兼容性追加。
    • Web 与桌面端复用 apps/dsa-web 的设置页展示逻辑,因此前端映射修复可同时覆盖桌面端。
    • 保留现有“本次测试模型”和“基础连接测试默认使用模型列表首项”的提示,不改变模型选择逻辑。
    • 不修改 secrets、workflow、deploy、migration 或外部服务配置。

Rollback Plan

  • git revert <merge-commit> 回滚本 PR 提交,重点确认 apps/dsa-web/src/components/settings/LLMChannelEditor.tsx, apps/dsa-web/src/components/settings/__tests__/LLMChannelEditor.test.tsx, docs/CHANGELOG.md, docs/LLM_CONFIG_GUIDE.md 恢复正常。

Acceptance Criteria

  • 后端识别 your request was blocked、request was blocked、blocked by policy、moderation_blocked 等明确拦截信号,并返回 request_blocked 或 details.reason=provider_blocked。
  • 上述 blocked 错误不再被归类为 network_error 或 unknown_error。
  • 前端对新增分类显示“请求被拦截”或“服务商拒绝请求”类文案,hint 指向账号风控、地域限制、模型权限、网关策略、内容安全策略或请求来源限制。
  • 既有 quota、model disabled、网络异常等分类行为不回归。
  • 补充后端分类测试、前端展示测试,并按扁平格式更新 docs/CHANGELOG.md 的 [Unreleased]。

Checklist

  • 本 PR 有明确动机和业务价值 / This PR has a clear motivation and value
  • 已提供可复现的验证命令与结果 / Reproducible verification commands and results are included
  • 已评估兼容性与风险 / Compatibility and risk have been assessed
  • 已提供回滚方案 / A rollback plan is provided
  • 已同步更新相关文档与 docs/CHANGELOG.md,并在 PR 描述中说明文档落点 / Relevant docs and docs/CHANGELOG.md are updated, and the documentation location is stated in this PR

Copilot AI review requested due to automatic review settings May 7, 2026 15:23
@github-actions github-actions Bot added configuration documentation Improvements or additions to documentation size/M testing labels May 7, 2026
@github-actions

github-actions Bot commented May 7, 2026

Copy link
Copy Markdown

🤖 自动审查报告

项目 结果
📊 变更文件 7 个
➕ 新增行数 115 行
➖ 删除行数 0 行
🔍 静态检查 ✅ 通过
🧠 AI 审查 ✅ 已完成

📁 修改的文件

  • 📝 apps/dsa-web/src/components/settings/LLMChannelEditor.tsx (+3/-0)
  • 📝 apps/dsa-web/src/components/settings/__tests__/LLMChannelEditor.test.tsx (+41/-0)
  • 📝 docs/CHANGELOG.md (+2/-0)
  • 📝 docs/LLM_CONFIG_GUIDE.md (+1/-0)
  • 📝 docs/LLM_CONFIG_GUIDE_EN.md (+1/-0)
  • 📝 src/services/system_config_service.py (+39/-0)
  • 📝 tests/test_system_config_service.py (+28/-0)

💡 提示: 请确保代码已通过本地测试,并遵循项目代码规范。

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

该 PR 针对 LLM 渠道“测试连接 / 获取模型”失败诊断进行细分:将明确的上游/网关拦截(blocked)从“网络异常”中拆分出来,并在前端以更贴近实际原因的文案与排障提示展示,从而避免误导用户排查 Base URL/TLS 等网络因素。

Changes:

  • 后端新增 blocked 信号识别(如 your request was blocked / blocked by policy / moderation_blocked),并返回 error_code=request_blockeddetails.reason=provider_blocked
  • Web 设置页新增 request_blocked 的错误标签与排障提示,并补充对应前端测试用例。
  • 补充后端分类测试用例,并更新 docs/CHANGELOG.md 的 [Unreleased] 条目。

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
apps/dsa-web/src/components/settings/LLMChannelEditor.tsx 增加 request_blocked 的 label/hint/reason hint 映射,确保 blocked 类错误不再使用网络排障话术。
apps/dsa-web/src/components/settings/tests/LLMChannelEditor.test.tsx 新增用例验证 blocked 场景展示“请求被拦截”及对应提示,并避免出现网络类提示。
docs/CHANGELOG.md 追加本次修复的 Unreleased 变更记录条目。
src/services/system_config_service.py 后端分类器新增 provider/gateway blocked 信号识别,并在 HTTP 错误与异常路径统一产出结构化诊断。
tests/test_system_config_service.py 增加 blocked 相关的诊断分类单测覆盖(exception + /models discovery HTTP 403)。

Comment thread docs/CHANGELOG.md Outdated
Comment on lines 18 to 20
- [修复] 修正 LLM 渠道测试中 `Your request was blocked` 等上游拦截错误被误报为网络异常的问题。
- [chore] 清理仓库根目录:移除误入库的 `.codex`、`review.md` 跟踪记录,将 smoke 测试入口迁移到 `scripts/`、环境检查脚本迁移为 `scripts/check_env.py`,并将 LiteLLM YAML 示例迁移到 `docs/examples/`。
- [新功能] Web 设置页新增通知渠道一键测试,支持临时配置、耗时与脱敏 attempts 展示。

@ZhuLinsen ZhuLinsen left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

评审结论

  • 必要性:通过,将明确 blocked 类上游失败从网络异常中拆分,能减少 LLM 渠道测试排障误导。
  • 是否有对应 issue:有,Closes #1223
  • PR 类型:fix,修正 LLM 渠道测试错误分类与前端提示。
  • description 完整性:不完整,描述已覆盖动机、范围、回滚和 changelog,但验证结果仍写 test:TIMEOUT,且 LLM/provider 相关改动缺少依赖运行时兼容性与外部错误信号来源说明。
  • 是否可直接合入:不可,需先补齐 LLM 兼容性/验证证据,并修正 PR 描述中的验证结果与当前 CI 成功状态不一致。

主要问题

  1. [Process blocker] PR 描述的验证证据与结构化事实不一致:描述中 ./scripts/ci_gate.sh offline-tests 结果为 test:TIMEOUT,但当前 CI 摘要显示 backend-gate:success。按 AGENTS.md,最终交付需要明确验证情况和未验证项;这里会让 reviewer 无法判断本地验证是否仍有超时缺口,建议更新为当前真实验证结论,或保留 timeout 但说明已由 CI 覆盖。
  2. [Process blocker] 本 PR 改动 LLM 渠道错误分类,并在前后端测试中涉及 provider/model/Base URL 类语义;但描述未说明这些 blocked 信号与当前 LiteLLM/上游返回形态的兼容依据,也未说明旧行为回退路径之外的运行时兼容验证。虽然 diff 看起来是追加分类,不迁移或清空用户配置,但按仓库对 LLM 配置相关变更的稳定性要求,合并前应补充:错误信号来源依据、当前依赖/运行时验证覆盖、既有 quota/model disabled/network 分类不回归的证据。

🤖 此回复由 OpenReview Bot 自动生成,仅供参考。如有疑问请 @维护者。

@ZhuLinsen ZhuLinsen left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

评审结论

  • 必要性:通过,明确区分上游/网关 blocked 类失败可以减少 LLM 渠道测试排障误导。
  • 是否有对应 issue:有,Closes #1223
  • PR 类型:fix,修正 LLM 渠道测试错误分类与前端展示提示。
  • description 完整性:不完整,已覆盖动机、范围、验证、风险和回滚,但 LLM/provider 相关错误信号缺少官方来源或运行时兼容性依据说明。
  • 是否可直接合入:不可,需先补齐外部 LLM/API 错误信号依据与兼容性验证说明;当前 CI 已通过,mergeable_state=blocked 本身不构成阻断。

主要问题

  1. [Process blocker] src/services/system_config_service.py 新增对 your request was blockedblocked by policymoderation_blocked 等上游错误信号的分类,属于 LLM/provider 兼容语义变更。PR 描述目前没有给出这些错误信号来自哪些服务商、网关或 LiteLLM 表现的官方/可核验来源,也没有说明当前锁定依赖和运行时是否覆盖该分类路径。按仓库 AGENTS.md 对外部模型/API 兼容风险的要求,合并前需要补充来源依据、兼容性验证结果,以及确认该变更仅追加诊断分类、不迁移或清理用户配置。
  2. [Nice to have] docs/CHANGELOG.md 已按扁平格式补充条目,但新增条目插入在 [Unreleased] 既有列表中间;文件注释要求新条目追加到本段末尾。该项不影响运行时行为,但建议移动到当前列表末尾以降低后续合并冲突。

🤖 此回复由 OpenReview Bot 自动生成,仅供参考。如有疑问请 @维护者。

@ZhuLinsen ZhuLinsen left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

评审结论

  • 必要性:通过,明确 blocked 类上游失败可减少 LLM 渠道测试被误判为网络异常的排障误导。
  • 是否有对应 issue:有,Closes #1223
  • PR 类型:fix,修正 LLM 测试错误分类与前端提示。
  • description 完整性:不完整,已覆盖动机、范围、验证、风险和回滚,但新增 LLM/provider blocked 信号仍缺少外部错误来源或兼容性依据链接。
  • 是否可直接合入:不可,需先补齐外部 LLM/API blocked 信号依据或说明其来源、当前 LiteLLM/HTTP 两条路径的兼容性验证边界;当前 CI 已成功,mergeable_state=blocked 本身不构成阻断。

主要问题

  1. [Process blocker] src/services/system_config_service.py 新增 request_blocked/provider_blocked 诊断分类,基于 Your request was blockedblocked by policymoderation_blocked 等 provider/gateway 错误文本分流。PR 描述和 changelog 已说明不触发用户配置迁移或清理,测试也覆盖了 litellm.completion/models 路径,但仍未给出这些外部错误信号的来源依据或适用边界。由于本次属于 LLM/provider 兼容语义变更,建议补充官方文档/公告链接,或明确说明这些信号来自本项目 issue 复现日志并限定为诊断性字符串匹配,避免后续把非 provider blocked 的错误误归类为服务商拦截。

🤖 此回复由 OpenReview Bot 自动生成,仅供参考。如有疑问请 @维护者。

@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: 66b4322cf5

ℹ️ 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 on lines +94 to +96
"request was blocked by safety",
"request was blocked by policy",
"request has been blocked by provider safety",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Match plain request-was-blocked messages

For upstream responses that say Request was blocked. or Request was blocked by regional restrictions without the word “your” and without the specific safety/policy suffixes, none of these tokens match, so _classify_llm_exception/_classify_llm_http_error still fall through to the generic auth/network paths instead of returning request_blocked. The stated acceptance criteria include plain “request was blocked”, so add that broader token (or an equivalent bounded regex) to cover those provider/gateway messages.

Useful? React with 👍 / 👎.

@ZhuLinsen ZhuLinsen left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

评审结论

  • 必要性:通过,拆分 blocked 类 LLM 测试失败能减少把服务商/网关拦截误判为网络问题的排障成本。
  • 是否有对应 issue:有,Closes #1223
  • PR 类型:fix,修正 LLM 渠道测试错误分类与前端提示。
  • description 完整性:不完整,已包含动机、范围、验证、风险和回滚,但缺少新增 blocked 信号来源/兼容边界说明,且未说明相关 LLM 排障文档是否需要同步。
  • 是否可直接合入:不可,当前 CI 已成功,mergeable_state=blocked 本身不构成阻断;阻断点是实现未覆盖 PR acceptance criteria 中明确写到的 plain request was blocked 场景。

主要问题

  1. [Correctness blocker] src/services/system_config_service.py 当前 _LLM_PROVIDER_BLOCKED_TOKENS 只匹配 your request was blockedrequest was blocked by policy/safety 等带限定词的文本,未匹配 plain Request was blocked.。这与 PR 描述/Acceptance Criteria 中的 request was blocked 不一致;该场景在 /models 的 403 响应下仍可能继续落到 auth/api_key_rejected,在 litellm.completion 异常下也可能落到更泛化分类,用户仍会看到误导性诊断。建议补充该精确文案的后端回归测试,并在避免误伤本地 firewall/policy 文案的前提下修正匹配规则。
  2. [Process blocker] 本 PR 涉及 LLM/provider 错误信号分类,虽然代码注释和 changelog 已把来源收窄为 Issue #1223 复现日志与回归路径,但 PR 描述仍未给出上游原始错误样本、官方/服务商来源链接或明确的兼容边界说明。按仓库对外部模型/API 兼容风险的审查要求,合入前需要补齐这部分依据;同时说明本次不触发用户配置迁移或清理,回退方式为 revert 本 PR 即可。
  3. [Nice to have] docs/CHANGELOG.md 已更新,仓库也已有 LLM 配置/排障通用文档入口,但本次新增的 request_blocked/provider_blocked 语义未在相关 LLM provider 排障文档中说明。由于这是设置页用户可见诊断行为,建议补充文档落点,或在 PR 描述中明确为何 changelog 已足够。

🤖 此回复由 OpenReview Bot 自动生成,仅供参考。如有疑问请 @维护者。

@ZhuLinsen ZhuLinsen left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

评审结论

  • 必要性:通过,拆分明确 blocked 类 LLM 测试失败能减少把服务商/网关拦截误判为网络异常的排障成本。
  • 是否有对应 issue:有,Closes #1223
  • PR 类型:fix,修正 LLM 渠道测试错误分类与前端诊断提示。
  • description 完整性:完整,已覆盖动机、范围、验证、风险、回滚、文档落点;LLM 外部信号已收窄为 Issue #1223 复现路径的诊断性匹配,并说明不触发配置迁移或清理。
  • 是否可直接合入:可,当前 CI 全部成功,双语文档与 docs/CHANGELOG.md 已按 AGENTS 要求同步;mergeable_state=blocked 本身仅反映仓库保护规则,不构成代码阻断。

🤖 此回复由 OpenReview Bot 自动生成,仅供参考。如有疑问请 @维护者。

@ZhuLinsen ZhuLinsen closed this May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

configuration documentation Improvements or additions to documentation size/M testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] LLM 渠道测试将 Your request was blocked 误报为网络异常

2 participants