tju-yxq opened a new issue, #5505:
URL: https://github.com/apache/rocketmq-dashboard/issues/5505

   ## Problem
   
   The alert rule form's four scope fields (`consumerGroup`, `topic`, 
`clusterName`, `brokerName`) are saved **raw** while the same form's 
notification-template preview **trims** the same fields before rendering. A 
pasted value with invisible padding produces a rule whose saved scope disagrees 
with the preview the user confirmed: the preview shows `order-topic`, but the 
rule list, edit form, and rule transfer/export carry `  order-topic  ` — and 
the evaluation selector matches nothing (or a different entity) because the 
backend persists and echoes the scope fields raw 
(`MybatisPlusAlertRepository.java:346-351`) while trimming only the rule name 
and evaluation selectors (`AlertService.java:171/198/765`).
   
   ## What did you do (steps to reproduce)?
   
   1. Open the alert rules page and create (or edit) a rule; paste a consumer 
group or topic name copied from a ticket/console with leading/trailing 
whitespace.
   2. Fill in the notification template; the preview renders the trimmed name 
(it trims via `Form.useWatch` + `.trim()` at lines ~271-285).
   3. Save the rule. The rule list and the edit form show the padded value — 
the stored scope disagrees with the preview the user approved.
   
   ## What did you expect to see?
   
   The saved rule's scope fields match what the notification preview showed.
   
   ## What did you see instead?
   
   The saved rule carries the padded value; the evaluation selector disagrees 
with the confirmed preview.
   
   ## Root cause
   
   `web/src/pages/ops/alerts.tsx` `handleSubmit` (around line 799):
   
   ```ts
   const values = await form.validateFields();
   const payload = { ...attachThresholdUnit(values), ... } as 
Partial<AlertRule>;
   ```
   
   while the same file's preview (lines ~271-285) trims the identical fields:
   
   ```ts
   typeof previewConsumerGroup === 'string' && previewConsumerGroup.trim()
     ? previewConsumerGroup.trim()
     : undefined
   ```
   
   ## Expected behavior
   
   - The four scope fields are trimmed in `handleSubmit` before the 
create/update payload is built.
   - The notification preview, the saved rule, the edit form, and the rule 
transfer all agree.
   
   ## Acceptance criteria
   
   - [ ] A padded pasted scope value is stored trimmed.
   - [ ] The saved rule matches the previewed notification template.
   - [ ] All other form values (name, threshold, description, notification 
template) are unchanged.
   
   ## Environment
   
   Branch `rocketmq-studio` at `6a68042f`; file: `web/src/pages/ops/alerts.tsx`.
   
   ## Duplicate check
   
   Searched open and closed issues for `alert rule trim`, `scope padding`, 
`preview disagrees`: nothing covers the save-vs-preview trim gap.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to