Frun1na opened a new issue, #6766:
URL: https://github.com/apache/rocketmq-dashboard/issues/6766

   ### Before Creating the Bug Report
   
   - [x] I have searched the [open 
issues](https://github.com/apache/rocketmq-dashboard/issues) of this repository 
and believe that this is not a duplicate.
   - [x] This is a defect in RocketMQ Studio, not a usage question and not a 
defect in another Apache RocketMQ repository.
   - [x] I can reproduce this on the current `rocketmq-studio` branch, or I 
have stated the exact version I am running below.
   
   ### Studio Version
   
   branch: rocketmq-studio
   git commit id: a92c2314
   deployed as: reproduced by a unit test against that commit
   
   ### Runtime Environment
   
   OS: not applicable — the defect is in the frontend Mock data source
   MySQL: not applicable — the defect is in the frontend Mock data source
   browser (for UI issues): not required to observe it; the defect is in the 
service layer
   
   ### Connected RocketMQ Cluster
   
   not applicable — reproduced with the frontend Mock data source in a unit test
   
   ### Describe the Bug
   
   With the frontend in Mock mode, ending a maintenance window that the Mock 
store does not have reports success.
   
   `web/src/services/opsService.ts:484` deletes a stored maintenance window by 
rebuilding the array and returning unconditionally:
   
   ```ts
   export async function deleteAlertSilence(id: number): Promise<void> {
     if (!isMockMode()) return opsApi.deleteAlertSilence(id);
     alertSilencesState = alertSilencesState.filter((silence) => silence.id !== 
id);
   }
   ```
   
   When `id` is in the store that `filter` removes the row, so the success 
result is right. When `id` is **not** in the store, `filter` removes nothing 
but the function still resolves `undefined`, i.e. it reports a deletion that 
never happened.
   
   The endpoint it stands in for does not do that. `DELETE 
/api/alert-silences/{id}` reaches `AlertSilenceService.delete` 
(`server/src/main/java/org/apache/rocketmq/studio/ops/alert/AlertSilenceService.java:81`),
 which throws when the row is gone:
   
   ```java
   if (!repository.deleteById(id)) {
       throw new BusinessException(404, "Alert silence not found: " + id);
   }
   ```
   
   The page trusts the service result. `deleteSilence` in 
`web/src/pages/ops/systemAlerts.tsx:478` runs the call, then ends the row and 
toasts, and only the `catch` branch reports the failure:
   
   ```ts
   await deleteAlertSilence(id);
   const nextPage = silences.length === 1 && silencePage > 1 ? silencePage - 1 
: silencePage;
   setSilencePage(nextPage);
   await loadSilences(nextPage);
   message.success(t('sysAlerts.silenceEnded'));
   } catch {
   message.error(t('sysAlerts.silenceEndFailed'));
   ```
   
   So against a real backend the operator is told the maintenance window could 
not be ended, and against the Mock data source the same click is reported as 
ended. The same Mock-mode contract drift was reported for the alert-rule, 
topic, consumer-group and ACL deletes (#6331, #6043, #920); the 
maintenance-window delete was not part of those, and neither #6331 nor its fix 
covers it.
   
   ### Steps to Reproduce
   
   Enable the frontend Mock data source, then call the service with an id no 
maintenance window has:
   
   ```text
   deleteAlertSilence(Number.MIN_SAFE_INTEGER)
   ```
   
   Or through the UI: open the system alerts page, start a maintenance window, 
end it from a second tab so the first tab's row is stale, then end the stale 
row from the first tab.
   
   ### What Did You Expect to See?
   
   The call rejects with the endpoint's message `Alert silence not found: 
<id>`, the way `deleteAclRule`, `deleteAclUser`, `deleteInstance`, 
`deleteK8sCert`, `deleteNameServer` and `acknowledgeAlert` already do in Mock 
mode, so `deleteSilence` takes its existing `sysAlerts.silenceEndFailed` branch 
and the stale row stays on screen to be refreshed.
   
   ### What Did You See Instead?
   
   The call resolved `undefined` without changing the store. The page marked 
the maintenance window as ended and toasted `sysAlerts.silenceEnded`, so the 
operator believed an active maintenance window had been closed when it had not.
   
   ### Additional Context
   
   A fix with a regression test follows in a pull request.
   
   ### Are You Willing to Submit a Pull Request?
   
   - [x] Yes, I am willing to submit a pull request.
   


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