Skip to content

Commit 66b4322

Browse files
committed
fix(review-feedback-1224): address latest review comments
1 parent aea8058 commit 66b4322

3 files changed

Lines changed: 21 additions & 6 deletions

File tree

docs/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
1717
- [修复] 修正 LLM 渠道测试中 `Model disabled` 被误报为网络异常的问题,并在失败提示中展示本次实际测试模型。
1818
- [chore] 清理仓库根目录:移除误入库的 `.codex``review.md` 跟踪记录,将 smoke 测试入口迁移到 `scripts/`、环境检查脚本迁移为 `scripts/check_env.py`,并将 LiteLLM YAML 示例迁移到 `docs/examples/`
1919
- [新功能] Web 设置页新增通知渠道一键测试,支持临时配置、耗时与脱敏 attempts 展示。
20-
- [修复] 修正 LLM 渠道测试中 `Your request was blocked` 等上游拦截错误被误报为网络异常的问题;新增阻断分类仅为诊断信号,不触发用户配置迁移或清理。
20+
- [修复] 修正 LLM 渠道测试中 `Your request was blocked` 等上游拦截错误被误报为网络异常的问题;新增阻断分类为诊断性字符串匹配(`Your request was blocked``blocked by policy``moderation_blocked`),仅覆盖 [Issue #1223](https://github.com/ZhuLinsen/daily_stock_analysis/issues/1223) 复现与回归路径(`litellm.completion``/models`,不触发用户配置迁移或清理。
2121
- [测试] 补充 LLM 渠道连接测试与模型发现失败分流的回归用例(含 `request_blocked/provider_blocked``model_access_denied``quota``network_error` 的边界),覆盖 `Your request was blocked``request has been blocked by policy` 等上游拦截信号,兼容性验证覆盖 `litellm.completion``/models` 两条执行路径。
2222

2323
## [3.15.0] - 2026-05-05

src/services/system_config_service.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,13 @@ class SystemConfigService:
8787

8888
_LLM_CAPABILITY_ORDER: Tuple[str, ...] = ("json", "tools", "stream", "vision")
8989
_LLM_STREAM_CHUNK_LIMIT = 8
90+
# 仅对现有复现与回归样本中的上游拦截文案做 best-effort 识别(来源:Issue #1223 复现日志 + 回归覆盖);
91+
# 该分类只用于诊断展示,不作为配置迁移或清理触发条件。
9092
_LLM_PROVIDER_BLOCKED_TOKENS: Tuple[str, ...] = (
9193
"your request was blocked",
92-
"request was blocked",
93-
"request has been blocked",
94-
"request is blocked",
95-
"request blocked",
94+
"request was blocked by safety",
95+
"request was blocked by policy",
96+
"request has been blocked by provider safety",
9697
"blocked by safety",
9798
"blocked by policy",
9899
"blocked by content",
@@ -2676,7 +2677,7 @@ def _has_model_access_denied_signal(text: str) -> bool:
26762677

26772678
@staticmethod
26782679
def _has_provider_blocked_signal(text: str) -> bool:
2679-
"""Match known upstream provider/gateway blocked signals for diagnostic classification.
2680+
"""Match explicit upstream provider/gateway blocked signals for diagnostic classification.
26802681
26812682
These markers are only used to surface a dedicated `request_blocked` reason
26822683
in runtime checks and do not mutate or migrate persisted user config.

tests/test_system_config_service.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,7 @@ class RateLimitError(Exception):
14151415
(Exception("request was blocked by policy"), "request_blocked", "provider_blocked"),
14161416
(Exception("This request has been blocked by provider safety policy."), "request_blocked", "provider_blocked"),
14171417
(Exception("moderation_blocked"), "request_blocked", "provider_blocked"),
1418+
(Exception("Request was blocked by local firewall rule."), "network_error", "unknown_error"),
14181419
(Exception("LLM Provider NOT provided for model foo"), "model_not_found", "provider_prefix_mismatch"),
14191420
]
14201421

@@ -1504,6 +1505,12 @@ def test_discover_llm_channel_models_classifies_error_scenarios(self, mock_get)
15041505
blocked_response.json.return_value = {"error": {"message": "Your request was blocked."}}
15051506
blocked_by_policy_response = Mock(ok=False, status_code=403, text="Request has been blocked by policy filter.")
15061507
blocked_by_policy_response.json.return_value = {"error": {"message": "Request has been blocked by policy filter."}}
1508+
blocked_by_firewall_response = Mock(
1509+
ok=False,
1510+
status_code=400,
1511+
text="Request was blocked by local firewall policy.",
1512+
)
1513+
blocked_by_firewall_response.json.return_value = {"error": {"message": "Request was blocked by local firewall policy."}}
15071514
invalid_json_response = Mock(ok=True, status_code=200, text="<html>bad gateway</html>")
15081515
invalid_json_response.json.side_effect = ValueError("invalid json")
15091516

@@ -1516,6 +1523,13 @@ def test_discover_llm_channel_models_classifies_error_scenarios(self, mock_get)
15161523
(rate_limit_response, "quota", "model_discovery", True, "rate_limit"),
15171524
(blocked_response, "request_blocked", "model_discovery", False, "provider_blocked"),
15181525
(blocked_by_policy_response, "request_blocked", "model_discovery", False, "provider_blocked"),
1526+
(
1527+
blocked_by_firewall_response,
1528+
"network_error",
1529+
"model_discovery",
1530+
False,
1531+
"http_error",
1532+
),
15191533
(invalid_json_response, "format_error", "response_parse", False, "non_json"),
15201534
]:
15211535
with self.subTest(error_code=error_code):

0 commit comments

Comments
 (0)