Repository navigation
Description
Studio Version
Trunk rocketmq-studio @ 4c697f07 (line references are as of that commit).
Problem
POST /api/alert-rules/update and POST /api/cluster-alert-rules/update replace every editable field of a rule, but an update body that simply omits an optional field does not clear it. MybatisPlusAlertRepository.replaceRule (server/src/main/java/org/apache/rocketmq/studio/ops/alert/MybatisPlusAlertRepository.java:141-146) builds the entity with toRuleEntity and calls ruleMapper.updateById(entity). MyBatis-Plus's default NOT_NULL update strategy omits null entity fields from the UPDATE's SET clause, so the previous value silently survives.
The service path makes the mismatch worse: AlertService.updateRule (AlertService.java:190-223) validates the submitted VO, replaces the stored rule, and returns the submitted VO. So the API responds with the field cleared (consumerGroup: null, severity: null, ...), the UI renders the cleared value, and the next GET shows the old value back.
Fields affected (all nullable in rmq_alert_rule, all accepted-as-null by NativeAlertRulePolicy.validate and AlertRuleRequestDTO): thresholdUnit, duration, channels, description, brokerName, clusterName, severity, instanceId (for Prometheus-rule metrics only — native metrics require it), consumerGroup, topic, notificationTemplate.
A concrete failure: a business consumer.lag.total rule scoped to consumerGroup="G1" cannot be re-scoped to all groups through the update API. The stale filter keeps narrowing alert evaluation while the operator believes it was removed.
Evidence
NativeAlertRulePolicy.validateonly rejects a missinginstanceIdfor native metrics (NativeAlertRulePolicy.java:66-71); a nullconsumerGroup/topic/severity/durationpasses (AlertRuleDuration.parse(null)returns ZERO).replaceRule→ruleMapper.updateById(toRuleEntity(rule))with the entity's optional fields null — MyBatis-Plus skips them in the SET clause (no globalupdate-strategyoverride inapplication.yml, no@TableField(updateStrategy=...)onRmqAlertRule).- The codebase already documents this exact behaviour for the sibling path and works around it:
NameserverRegistryService.clearOmittedOptionalColumns(cluster/nameserver/NameserverRegistryService.java:147-172, merged PR fix(studio): persist cleared optional instance and registry fields #4466, "MyBatis-Plus updateById omits null entity fields... assign those columns explicitly"), andMybatisPlusInstanceRepository.java:128-131does the same for a cleared credential reference. The alert-rule path is the one missing it.
Impact
- Scope filters (
instanceId/consumerGroup/topic/brokerName/clusterName) cannot be cleared, so alerts keep evaluating against a stale narrower scope than the UI shows. severity/duration/channels/notificationTemplate/descriptionsilently revert to their previous values after an update that omitted them, contradicting the 200 response.- The silent divergence between the response and the stored row is undetectable from the client.
Expected behavior
An update that omits an optional field clears it, and the stored rule matches the response — the same contract the registry and instance paths already implement.
Related work
- fix(studio): persist cleared optional instance and registry fields #4466 (merged 2026-09-21): the same defect class fixed for instance and nameserver-registry optional columns; did not touch alert rules.
- fix(nameserver): persist a cleared registry description and K8s columns #4277/fix(instance): persist a cleared admin credential reference #4276/fix(topic): allow a blank update to clear the persisted topic remark #4275 (closed/unmerged attempts in the same family) confirm the pattern is recognised by the project.
- [Studio][Bug] Updating or toggling an alert rule always wipes its FIRING/ACK state #4326 (open): toggling wipes FIRING/ACK state — a different field-lifecycle defect on the same table.
- fix(alert): keep a rule without a metric out of the reconcile membership test #4748 (open, mine): reconcile abort for rules without a metric — unrelated.
PR
Fix: #4784.
Activity
RockteMQ-AI commentedon Sep 21, 2026
Evaluation
Classification: Bug — MyBatis-Plus NOT_NULL update strategy prevents clearing optional fields
Severity: MEDIUM-HIGH
Status: ✅ Confirmed
Verification
Code references verified against
rocketmq-studio @ 4c697f07:MybatisPlusAlertRepository.replaceRule(lines 141-146):ruleMapper.updateById(toRuleEntity(rule))— MyBatis-Plus defaultNOT_NULLstrategy omits null fields from the UPDATE SET clause.AlertService.updateRule(lines 190-223): validates, replaces, then returns the submitted VO — API response shows cleared fields, but the database retains stale values.NameserverRegistryService.clearOmittedOptionalColumns(fix(studio): persist cleared optional instance and registry fields #4466) andMybatisPlusInstanceRepository(lines 128-131) already work around this exact MyBatis-Plus behavior for other paths. The alert-rule path is the remaining gap.Impact
consumerGroup,topic,brokerName,clusterName,instanceId) cannot be cleared via the update API — alerts keep evaluating against a stale narrower scope.severity/duration/channels/notificationTemplate/descriptionalso cannot be cleared.Cluster Context
This is the same MyBatis-Plus
NOT_NULLdefect class as #4272 (topic remark), #4273 (admin credential, HIGH security), #4274 (NameServer fields). The alert-rule path is another instance.Associated PR
PR #4784 (by @unbridled-41) — fix: persist cleared optional columns when an alert-rule update omits them.
Evaluated by github-manager bot
lizhimins commentedon Sep 24, 2026
Fixed in 6ef2f2d (#4784) on the
rocketmq-studiobranch.Closing manually: GitHub only auto-closes an issue when the pull request is merged into the repository's default branch, and
rocketmq-studiois not it.