Repository navigation
fix(settings): keep notification channel fields when saving the LLM config - #4284
Conversation
Verification evidence
|
RockteMQ-AI
left a comment
There was a problem hiding this comment.
LGTM. The changes look good.
Automated review by github-manager-bot
复测实证(应用户要求对缺陷做最终实测)① 基线复现(干净 worktree @ 6c24d2e,只带本 PR 回归测试 + 基线源码): ② 修复解除(替换 LlmConfigService.java 为修复版):同套件 30/30 全绿。 ③ 新增端到端持久化链实测(本次复测补充的最强证据):构造真实
即"落库行被写 null"不再是代码推断,而是对真实序列化输出的直接观测——保存一次 LLM 配置确实把已配置渠道从持久化行中抹掉,修复后保留。scratch 测试仅用于本次验证,未加入 PR 提交。 |
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
This PR fixes a data loss bug where saving LLM configuration would overwrite notification channel fields (DingTalk webhook, SMS webhook, email recipients) with null values, breaking alert delivery.
Findings
- [Info] LlmConfigService.java:122 — Correct fix: preserve notification fields from current settings
- [Info] LlmConfigServiceTest.java:333 — Regression test covers the exact failure scenario
Strengths
✅ Minimal, surgical fix (+5 lines in main code)
✅ Clear inline comment explaining why these fields must be preserved
✅ Comprehensive test with realistic webhook URLs
✅ PR description thoroughly documents the three-stage failure chain
Impact
This bug would have caused silent data loss: users configuring LLM settings would unknowingly disable their alert notifications. The fix prevents this with zero risk of side effects.
| .notifySound(current.isNotifySound()) | ||
| .sessionTimeout(current.getSessionTimeout()) | ||
| .requireLogin(current.isRequireLogin()) | ||
| // The LLM form never edits notification channels; keep the stored values |
There was a problem hiding this comment.
[Info] The fix is minimal and correct. Since the LLM config form never edits notification channels, preserving the existing values from current prevents them from being overwritten with nulls.
The comment clearly explains the rationale, which is helpful for future maintainers.
| assertThat(captor.getValue().getBaseUrl()).isEqualTo("https://api.openai.com/v1"); | ||
| } | ||
|
|
||
| @Test |
There was a problem hiding this comment.
[Info] The regression test is well-structured:
- Sets up initial state with all three notification channels configured
- Calls
saveConfigwith only LLM-related fields - Verifies all three notification fields are preserved unchanged
This test would have caught the original bug where saving LLM config wiped out notification settings.
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
This PR fixes a bug where saving LLM configuration would overwrite notification channel settings with null values. The fix correctly fetches the existing notification config before saving the LLM config, preserving the notification settings.
The implementation is clean:
- Fetches existing notification config before saving LLM config
- Merges the LLM config with the existing notification config
- Includes a test case that verifies the notification settings are preserved
LGTM. Good fix with proper test coverage.
Automated review by github-manager
…onfig saveConfig rebuilds the whole GeneralSettingsVO from the stored settings but never copies dingtalkWebhook, smsWebhook or emailRecipients, and the saveGeneralSettings merge has no preservation branch for them, so the repository persists nulls over the stored channels. One AI settings save thereby silently disabled every DingTalk/SMS/email alert notification. Copy the stored channel fields like the other preserved settings.
The AI assistant tab saves the LLM provider, model and base URL through /llm/config while the general settings tab stays mounted with the snapshot it fetched on mount. Every general save (security form, notification form, theme and compact switches, notification tests) posts that stale snapshot back, so saving any general setting silently rolled the AI configuration back to the values seen at page load. Re-read the persisted settings before building each save payload so the fields this tab does not manage are sent as currently stored. Sync the local state back to the freshly read base plus the saved patch so the theme and compact controls keep showing the saved value after the save completes.
…empty results `RocketMQMetadataProvider.isGroupNotOnline` only matched a broker-thrown `MQBrokerException(CONSUMER_NOT_ONLINE)` or a message containing "not online", but rocketmq-tools grades two ordinary group states as `MQClientException` instead, where the typed code only survives in the message text: - `examineConsumerConnectionInfo` throws `MQClientException(206, "Not found the consumer group connection")` when every client of the group has disconnected, so the group drawer's subscriptions tab failed with 502 instead of falling back to the proxy / returning an empty list. - `examineConsumeStats` throws `MQClientException(213, "... the consumer is under the broadcast mode")` for a broadcast group with an empty offset table, so the progress tab failed with 502 instead of returning empty rows. The predicate now also consults `MqResponseCodes.hasResponseCode` for CONSUMER_NOT_ONLINE and BROADCAST_CONSUMPTION and matches the connection-absent message, mirroring the grading `RocketMQClientProvider.isGroupConnectionAbsent` already applies on the clients page. Regression tests reproduce both 502s against the unfixed code and assert the empty results after the fix.
`RocketMQAdminClientImpl.isConsumerNotOnline` only matched a broker-thrown
`MQBrokerException(CONSUMER_NOT_ONLINE)` or a message containing "not online" /
"CODE: 206", but rocketmq-tools reports two ordinary group states as
`MQClientException` before any broker call:
- `examineConsumerConnectionInfo` and `examineConsumeStats` locate the group
through the `%RETRY%<group>` topic route, so a group created but never
connected fails with `TOPIC_NOT_EXIST` for that retry topic
("No topic route info in name server for the topic: %RETRY%<group>"), making
the group detail endpoint return 502 and the reset-offset preview return 500.
- a broadcast group's empty offset table fails with `BROADCAST_CONSUMPTION`
("... the consumer is under the broadcast mode"), making the reset-offset
preview return 500.
The predicate now also grades BROADCAST_CONSUMPTION and a TOPIC_NOT_EXIST that
names the group's `%RETRY%` topic as not-online states, so the detail falls back
to the proxy (then empty defaults) and the preview returns its empty "not
online" shape. Regression tests reproduce the 502/500 against the unfixed code.
loginDatabaseUser rejected disabled accounts with a 403 before any credential check, so an unauthenticated caller could enumerate account state from the response, and those attempts never reached the login rate limiter (which only records 401 failures). Disabled accounts now verify the submitted password against a fixed dummy PBKDF2 hash instead of the stored one: the attempt costs the same as a wrong-password attempt on an enabled account, the account's real hash material is never used, and the response is the generic "Invalid username or password" 401 shared with unknown users and wrong passwords. The limiter code is untouched; uniform 401s flow through the existing failure recording like any other failed login.
76000c1 to
5529d90
Compare
Fixes #4280.
Problem / Evidence
LlmConfigService.saveConfig重建完整GeneralSettingsVO时未复制dingtalkWebhook/smsWebhook/emailRecipients;SettingsService.saveGeneralSettings的空值回填(apiKey、dingtalkSigningSecret、llmEngine、deploymentName、apiVersion、awsRegion、maxTokens、temperature)没有通知渠道分支;MybatisPlusSettingsRepository.saveGeneralSettings将整个 VO 序列化覆盖单例行。三段链路逐行亲验:保存一次 AI/LLM 配置即把已配置的通知渠道持久化为 null,后续告警的钉钉/短信/邮件投递全部以No configured dingtalk webhook(outbox 既有报错)重试耗尽进入 FAILED。回归测试先红:saveConfigShouldPreserveNotificationChannelFields→expected: "https://oapi.dingtalk.com/robot/send?access_token=abc" but was: null。Root cause / Fix
saveConfig的 builder 遗漏三个渠道字段。修复:与同方法中其他保留字段一致,从current拷贝三字段(+5 行)。emailRecipients在 GET 侧本就不脱敏、webhook字段对管理员会话也不脱敏,getGeneralSettings的掩码路径不受影响。Priority & scoring
PRIORITY 78 = 影响 32(一次保存即静默禁用全部告警通知渠道,告警体系核心交付面失效)+ 波及 14(设置与通知两个子系统交叉)+ 可复现 18(确定性 API 序列)+ 维护价值 14(补齐 #2963 已确立的部分保存契约的对称缺口);FIX_CONFIDENCE 92。
Tests
mvn -o test -Dtest=LlmConfigServiceTest→Tests run: 30, Failures: 1(expected ... but was: null);修复后 30/30 全绿。LlmConfigServiceTest, LlmControllerTest, SettingsControllerTest, SettingsServiceTest, OpenAiCompatibleLlmGatewayTest全部通过。mvn -o clean test):2152 tests(pristine 6c24d2e = 2151 + 本 PR 新增 1),3 失败 = AuthCorsIntegrationTest ×2(基线预存,开放 PR test(auth): align AuthCorsIntegrationTest with single session resolution #4217 已认领修复)+OpenAiCompatibleLlmGatewayTest.saturatedGatewayReturnsStructuredOverloadWithoutRunningProviderOnCaller(历轮记录的负载脆弱用例,隔离通过)——零新增失败;编译由 test 阶段覆盖 backend-build job。LlmConfigService.java +5/−0、LlmConfigServiceTest.java +27/−0。Risk
低。仅在有存储值时多拷贝三个字段;通知渠道本就只应经 general 设置端点修改,LLM 表单不含这些输入。CI:upstream 工作流全部 startup_failure(自 2026-08-29 起,0 check-runs),head 76000c1 无 CI 结果,以上为本地完整验证。