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

   ### Which Issue(s) This PR Fixes
   
   - Fixes #5124
   
   ### Brief Description
   
   `MetadataService.sendMessage` 
(server/src/main/java/org/apache/rocketmq/studio/instance/topic/MetadataService.java:293)
 ended with a bare `return 
resolve(request.getInstanceId()).sendMessage(request);`, outside the 
`executeWithAudit` wrapper that every other cloud-capable write in the class 
uses. `AliyunInstanceProvider`/`TencentInstanceProvider` record nothing 
themselves, and the Apache path is the only one that writes `SEND_MESSAGE` 
(`RocketMQAdminClientImpl`), so a test message sent to an Aliyun or Tencent 
instance left no audit row — for the success as well as for the failure. The 
same method backs message redelivery (`redeliverMessage`) and the 
`rmq.message.send` AI tool, so those operations were silent on cloud instances 
too.
   
   The fix routes the send through the existing `executeWithAudit` wrapper: for 
a non-Apache provider it records `SEND_MESSAGE` / `MESSAGE` with the topic as 
the resource name, `SUCCESS` when the provider returns and `FAILED` with the 
provider's message when it throws (the exception is still propagated 
unchanged). The Apache vendor is still skipped, so the Apache row is not 
duplicated — `apacheTopicWriteOperationsShouldNotDuplicateProviderAudit` and 
`sendMessageShouldReturnResult` (which asserts 
`verifyNoInteractions(operationAuditService)`) stay green.
   
   ### How Did You Test This Change?
   
   Three new tests in `MetadataServiceTest`, all red on the unmodified tree:
   
   - `cloudSendShouldBeAuditedLikeTheApachePathTest` — a successful send on a 
`TENCENT` instance records `("SEND_MESSAGE", "MESSAGE", "orders", 
"cloud-instance", "tag=TagA, key=order-1", "SUCCESS", null)`;
   - `failedCloudSendShouldBeAuditedWithItsReasonTest` — a provider failure 
records the same row with `"FAILED"` and the provider message, and the 
exception still reaches the caller;
   - `cloudRedeliveryShouldBeAuditedLikeTheApachePathTest` — `redeliverMessage` 
on a cloud instance records the same row for the destination topic 
(`%RETRY%group-a`).
   
   Red run on the unmodified tree:
   
   ```
   $ cd server && mvn -B -ntp test -Dtest=MetadataServiceTest
   Wanted but not invoked:
   operationAuditService.record(
       "SEND_MESSAGE",
       "MESSAGE",
       "orders",
       "cloud-instance",
       "tag=TagA, key=order-1",
       "SUCCESS",
       null
   );
   Actually, there were zero interactions with this mock.
   [ERROR]   
MetadataServiceTest.cloudRedeliveryShouldBeAuditedLikeTheApachePathTest:794
   [ERROR]   
MetadataServiceTest.cloudSendShouldBeAuditedLikeTheApachePathTest:755
   [ERROR]   
MetadataServiceTest.failedCloudSendShouldBeAuditedWithItsReasonTest:773
   [ERROR] Tests run: 53, Failures: 3, Errors: 0, Skipped: 0
   [INFO] BUILD FAILURE
   ```
   
   Green run after the fix (same command, same test class):
   
   ```
   $ cd server && mvn -B -ntp test -Dtest=MetadataServiceTest
   [INFO] Tests run: 53, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 
4.106 s -- in org.apache.rocketmq.studio.instance.topic.MetadataServiceTest
   [INFO] Tests run: 53, Failures: 0, Errors: 0, Skipped: 0
   [INFO] BUILD SUCCESS
   ```
   
   `mvn` also runs checkstyle at `validate`; both runs report `You have 0 
Checkstyle violations.`
   
   ### Checklist
   
   - [x] One coherent change; unrelated modifications are not bundled in
   - [x] Commit subject follows Conventional Commits
   - [x] Tests added or updated for non-trivial changes
   - [x] New UI text has both Chinese and English entries under `web/src/i18n/` 
— not applicable, no UI text changed
   - [x] Architecture constraints stay green (`mvn test` runs the ArchUnit 
checks) — the change reuses the class's own audit wrapper, no new dependency
   - [x] New source files carry the ASF license header — no new source file
   - [x] Documentation touched where behaviour changed (README / `docs/` / 
in-app help) — not applicable: `SEND_MESSAGE` is already part of the documented 
audit vocabulary and the API shape is unchanged; `docs/api-spec.md` is owned by 
another change
   


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