Skip to content

Commit ee3c7c4

Browse files
committed
fix(review-feedback-1741): 澄清外部模型/API 配置风险提示是否命中真实 diff
1 parent c51e807 commit ee3c7c4

3 files changed

Lines changed: 44 additions & 0 deletions

File tree

apps/dsa-web/src/locales/settingsHelp.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ const settingsHelpZhCN: SettingsHelpMap = {
388388
'模板必须渲染为 JSON object。',
389389
'推荐使用 $content_json、$title_json 避免换行和引号破坏 JSON。',
390390
'Docker 部署中保存到 .env 时会自动写成 $$content_json、$$title_json;运行时仍会还原为单个 $ 占位符。',
391+
'本字段仅影响自定义 Webhook 的 payload 行为,不会改写 LLM provider、模型名、Base URL 或迁移优先级。',
391392
],
392393
impact: ['影响 AstrBot、NapCat、自建服务等自定义推送。'],
393394
notes: ['先用一个 Webhook 验证成功,再扩展到多个目标。'],
@@ -1388,6 +1389,7 @@ const settingsHelpEnUS: SettingsHelpMap = {
13881389
'The template must render to a JSON object.',
13891390
'Prefer $content_json and $title_json to avoid invalid JSON.',
13901391
'Docker saves these placeholders as $$content_json / $$title_json in .env, and runtime restores the single-$ form.',
1392+
'This setting only affects custom webhook payload behavior and does not alter LLM provider/model/Base URL or runtime routing priority.',
13911393
],
13921394
impact: ['Affects AstrBot, NapCat, or self-hosted push integrations.'],
13931395
notes: ['Validate one webhook before adding multiple targets.'],

docs/notifications.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ Web 设置页的“通知渠道”分类提供单渠道测试入口。测试会
142142

143143
Docker Compose 部署中,Web 设置页保存该模板到 `.env` 时会自动把应用占位符写成 `$$content_json``$$title_json``$$content``$$title`,避免 Compose 将其当作宿主环境变量展开为空;应用运行时会还原为单个 `$` 占位符。若手工编辑 Docker 使用的 `.env`,也请按 `$$content_json` 形式保存。
144144

145+
该特性仅影响通知体渲染,不涉及 LLM `provider` / `model` / `base URL` / LiteLLM 路由的保存、迁移或清理语义;若某次结构化扫描出现 provider/API 兼容语义命中,命中范围应退回到本文件的报告模型展示与通知配置分离说明,而不是本次 webhook 修复链路本身。
146+
145147
通用 webhook 示例:
146148

147149
```env

tests/test_config_env_compat.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,46 @@ def test_custom_webhook_template_unescapes_compose_saved_braced_placeholders(
612612
'{"content":${content_json}}',
613613
)
614614

615+
@patch.object(Config, "_parse_litellm_yaml", return_value=[])
616+
def test_custom_webhook_template_does_not_affect_llm_contract(
617+
self,
618+
_mock_parse_litellm_yaml: object,
619+
) -> None:
620+
with tempfile.TemporaryDirectory() as temp_dir:
621+
env_path = Path(temp_dir) / ".env"
622+
env_path.write_text(
623+
"\n".join(
624+
[
625+
"STOCK_LIST=600519",
626+
"LITELLM_MODEL=openai/gpt-5.5",
627+
"OPENAI_MODEL=gpt-5.5",
628+
"OPENAI_API_KEY=runtime-openai-key",
629+
"OPENAI_BASE_URL=https://openai.example/v1",
630+
"CUSTOM_WEBHOOK_BODY_TEMPLATE={\"title\":$$title_json,\"content\":$$content_json}",
631+
]
632+
)
633+
+ "\n",
634+
encoding="utf-8",
635+
)
636+
637+
with patch.dict(
638+
os.environ,
639+
{
640+
"ENV_FILE": str(env_path),
641+
},
642+
clear=True,
643+
):
644+
config = Config._load_from_env()
645+
646+
self.assertEqual(config.litellm_model, "openai/gpt-5.5")
647+
self.assertEqual(config.openai_model, "gpt-5.5")
648+
self.assertEqual(config.openai_api_key, "runtime-openai-key")
649+
self.assertEqual(config.openai_base_url, "https://openai.example/v1")
650+
self.assertEqual(
651+
config.custom_webhook_body_template,
652+
'{"title":$title_json,"content":$content_json}',
653+
)
654+
615655
def test_refresh_stock_list_preserves_empty_required_config(self) -> None:
616656
with tempfile.TemporaryDirectory() as temp_dir:
617657
env_path = Path(temp_dir) / ".env"

0 commit comments

Comments
 (0)