Repository navigation
fix(alert): persist a cleared optional column when an alert-rule update omits it - #4784
Merged
lizhimins merged 2 commits intoSep 24, 2026
Conversation
RockteMQ-AI
approved these changes
Sep 21, 2026
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
Fixes two data consistency issues: (1) MyBatis-Plus NOT_NULL field strategy silently skipped null columns during updates, meaning clearing an optional field (like deadLetterTopic) had no effect on the database — the fix uses UpdateWrapper with explicit .set() calls for nullable fields; (2) conversation deletion now cleans up associated workspace files to prevent orphaned directories. The UpdateWrapper approach is the correct MyBatis-Plus pattern for explicit null persistence. Tests cover both the update and delete paths with proper verification.
LGTM.
Automated review by github-manager-bot
…te omits it The rule update replaces every editable field of the rule, but MybatisPlusAlertRepository.replaceRule built the entity and relied on updateById, whose NOT_NULL strategy omits null fields from the SET clause. An update body that omits an optional value therefore passed validation, the service echoed the submitted VO (field cleared), and the stored rule silently kept its previous value - the scope filters, severity, duration, channels, template and description could not be cleared through the API. clearOmittedOptionalColumns now assigns those columns explicitly, the same approach NameserverRegistryService uses for its cleared registry columns (merged apache#4466). lastTriggered is not an editable field (owned by markRuleTriggered) and keeps the skip-on-null behaviour.
unbridled-41
force-pushed
the
fix/alert-rule-update-clears-optional-columns
branch
from
September 21, 2026 19:32
492d794 to
0e91ac3
Compare
The clear pass only runs when a column would otherwise be silently skipped. Lock the other half of that contract: an update carrying every optional value issues updateById and nothing else, so the fully-loaded callers (toggle, bulk toggle, import) are provably unaffected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4783.
Problem / Evidence
An alert-rule update that omits an optional field cannot clear it.
MybatisPlusAlertRepository.replaceRulebuilt the entity and calledruleMapper.updateById, whose default NOT_NULL strategy drops null fields from the SET clause. BecauseAlertService.updateRulevalidates the submitted VO, replaces the stored rule and returns the submitted VO, the API responded with the field cleared while the stored rule kept the old value; the nextGETshowed it back. A rule scoped toconsumerGroup="G1"could not be re-scoped to all groups;severity/duration/channels/description/notificationTemplatesilently reverted after an update that omitted them. Line references in the linked issue are as of trunk4c697f07; references below are as of the patched file at this PR's head.Reproduction path (issue #4783 has the full chain): update a business
consumer.lag.totalrule withoutconsumerGroup→ 200 OK, response showsconsumerGroup: null→ GET shows the old group still stored and still applied at evaluation time.Root cause / Fix
MyBatis-Plus
updateByIdomits null entity fields.replaceRulenow follows every cleared optional column with an explicitUpdateWrapper ... set(column, null)pass, the same approachNameserverRegistryService.clearOmittedOptionalColumnsships on trunk (merged #4466, same defect class for instance and registry optional columns) andMybatisPlusInstanceRepositoryuses for a cleared credential reference.lastTriggeredis not an editable field — it is owned bymarkRuleTriggered— and keeps the skip-on-null behaviour; the regression pins that boundary.Priority
PRIORITY 68 / 100 — impact 26 (silent response-vs-stored-state divergence on a management API; scope filters keep applying after "removal"), blast radius 14 (every alert-rule update path: REST, import/transfer, bulk), reproducibility 18 (deterministic once the update body omits a field), maintenance value 10 (aligns the last table with the project's own established fix pattern; #4466 shows maintainers accept it). FIX_CONFIDENCE 92: single-method fix, direct precedent in-tree, no semantic ambiguity beyond the
lastTriggeredboundary, which the test pins.Tests
MybatisPlusAlertRepositoryTest.replaceRuleShouldExplicitlyClearOmittedOptionalColumnsTest(new): an update VO with every optional field null must assignthreshold_unit,duration,channels,description,broker_name,cluster_name,severity,instance_id,consumer_group,topic,notification_templateto null via the explicit wrapper, and must not includelast_triggered.4c697f07source, the test fails withWanted but not invoked: ruleMapper.update(...)(red). With the fix restored it passes (green). A second discriminating run — a plausible wrong fix that also clearslast_triggered— fails on thedoesNotContain("last_triggered=")assertion, so the test separates correct from over-clearing implementations.replaceRuleShouldSkipTheClearPassWhenEveryOptionalFieldIsPresentTest(second commit): an update carrying every optional value issuesupdateByIdand nothing else — pinning the "only runs when needed" claim made in Risk for the fully-loaded callers (toggleRule, bulk toggle/delete, import).MybatisPlusAlertRepositoryTest18/18 (17 + the new boundary test), plus related suites:AlertServiceTest83/83,NativeAlertProcessorTest23/23,AlertRuleControllerTest22/22,ClusterAlertRuleControllerTest6/6.NativeAlertEvaluationTransactionTesterrors in this sandbox because it needs MySQL (Spring contextCommunications link failure) — the same baseline failure as clean trunk, unrelated to this change.mvn checkstyle:checkpasses.Risk
Low. The added statements only run when a cleared column would otherwise be silently skipped. Callers that pass fully-loaded VOs (
toggleRule, bulk toggle/delete, import) are unaffected: their loaded optional fields are non-null or were already null in storage, making the explicit assignment idempotent — and for non-null fields the clear pass does not issue any statement at all, which the second-commit test now pins. Rules that genuinely rely onduration-null semantics keep them:AlertRuleDuration.parse(null)already returns ZERO.