Frun1na opened a new pull request, #6772:
URL: https://github.com/apache/rocketmq-dashboard/pull/6772

   ### Which Issue(s) This PR Fixes
   
   - Fixes #6771
   
   ### Brief Description
   
   `NotificationOutboxService.sendEmail` composes the subject from the alert 
title as it stands
   (`NotificationOutboxService.java:494`): `message.setSubject("[RocketMQ 
Studio] " + alert.getTitle())`.
   The title is the rule's name verbatim (`NativeAlertProcessor.java:197` sets 
`.title(rule.getName())`),
   and nothing keeps that name to one line — `AlertRuleRequestDTO.name` carries 
only `@NotBlank` — so
   a rule created over the REST contract (AI tool, transfer import) can be named
   `High lag\nBcc: [email protected]`. A mail subject is a single header 
line, and the break was
   written into the header as it stood: the mail version the server ships emits
   `Subject: [RocketMQ Studio] High lag\r\n Bcc: [email protected]`, so the 
remainder of the rule
   name becomes a folded continuation of the header instead of subject text.
   
   Collapse CR/LF runs into spaces when composing the subject, the way 
`AlertService.sanitizeCommentText`
   (`AlertService.java:722`) keeps an exported rule comment on one line. A name 
without a break produces
   the byte-identical subject it produced before.
   
   ### How Did You Test This Change?
   
   ```
   cd server && mvn -B -ntp test -DforkCount=1 
-Dtest=NotificationOutboxServiceTest
   Tests run: 37, Failures: 0, Errors: 0, Skipped: 0   (checkstyle:check green 
in the same run)
   ```
   
   The delivery path's neighbours in the same package stay green as well:
   
   ```
   mvn -B -ntp test -DforkCount=1 
-Dtest=NotificationOutboxServiceTest,AlertNotificationTemplateTest,AlertSilenceServiceTest
   Tests run: 56, Failures: 0, Errors: 0, Skipped: 0
   BUILD SUCCESS (checkstyle:check green in the same run)
   ```
   
   The new test fails without the fix — the assertion reads the subject handed 
to
   `JavaMailSender.send`, and it still carries the line break:
   
   ```
   Tests run: 37, Failures: 1, Errors: 0, Skipped: 0
   
NotificationOutboxServiceTest.emailSubjectStaysOnOneLineForAMultiLineAlertTitleTest
 <<< FAILURE!
   Argument(s) are different! Wanted: javaMailSender.send(<custom argument 
matcher>);
   Actual invocations have different arguments:
   javaMailSender.send(SimpleMailMessage: [email protected]; 
subject=[RocketMQ Studio] High lag
   Bcc: [email protected]; text=[warning] High lag
   Bcc: [email protected] - high
   Labels: );
   -> at NotificationOutboxService.sendEmail(NotificationOutboxService.java:496)
   ```
   
   The assertion flips red only because of the fix: reverting 
`subjectLine(...)` in the subject line
   (keeping the new test) reproduces exactly that failure.
   
   ### Other consumers
   
   The alert title is the rule name, and it reaches several surfaces; only the 
mail subject is a
   one-line slot:
   
   | Surface | Status |
   | --- | --- |
   | Email subject (`NotificationOutboxService:494`) | fixed here |
   | Message body (`${title}` of the rendered template) and the 
DingTalk/SMS/webhook JSON `title`/`content` | already correct: a line break is 
legitimate content there (JSON escapes it); unchanged |
   | Console alerts table `title` cell | already correct: a table cell renders 
wrapped text |
   | Prometheus export | already correct: `alertName()` strips every character 
outside `[A-Za-z0-9_]`, and the skipped-rule note goes through 
`sanitizeCommentText` |
   | AI tool / REST JSON responses carrying the alert title | already correct: 
JSON-escaped strings |
   
   ### Checklist
   
   - [x] One coherent change; unrelated modifications are not bundled in
   - [x] Commit subject follows Conventional Commits (`feat:` / `fix:` / 
`refactor:` / `chore:` / `docs:` / `perf:`)
   - [x] Tests added or updated for non-trivial changes, test methods named 
`...Test`
   - [ ] New UI text has both Chinese and English entries under `web/src/i18n/`
   - [ ] Architecture constraints stay green (`mvn test` runs the ArchUnit 
checks)
   - [ ] New source files carry the ASF license header
   - [ ] Documentation touched where behaviour changed (README / `docs/` / 
in-app help)
   


-- 
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