Frun1na opened a new issue, #6510: URL: https://github.com/apache/rocketmq-dashboard/issues/6510
### 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: `779b8c0e` deployed as: reproduced by a unit test against that commit (the affected code is the web client's demo data source) ### Runtime Environment OS: Ubuntu on WSL2 MySQL: not applicable — the defect is in the web client's demo (mock) data source browser: not applicable — reproduced in a vitest unit test ### Connected RocketMQ Cluster RocketMQ version: not applicable — the defect does not need a cluster access mode: not applicable deployment: not applicable ### Describe the Bug Exporting a Grafana dashboard whose uid is not in the demo inventory answers with a fabricated document instead of the 404 the endpoint documents: ```ts // web/src/services/grafanaService.ts:32-39 export async function exportGrafanaDashboard(uid: string): Promise<Blob> { if (isMockMode()) { const found = mockGrafanaDashboards.find((dashboard) => dashboard.uid === uid); const model = found ? found.model : { uid }; return new Blob([JSON.stringify(model, null, 2)], { type: 'application/json' }); } return metricsApi.exportGrafanaDashboard(uid); } ``` The same file already throws for that lookup (`getGrafanaDashboard`, `:21-30`), and the endpoint the mock stands in for answers 404: `GrafanaDashboardController.exportDashboard` calls `GrafanaDashboardService.getDashboardJson`, which throws `BusinessException(404, "Grafana dashboard not found: " + uid)` (`server/src/main/java/org/apache/rocketmq/studio/cluster/metrics/grafana/GrafanaDashboardService.java:125-129`); the operation is annotated `@ApiResponse(responseCode = "404", description = "Dashboard uid is unknown")`. Because the call resolves, `GrafanaDashboardList.handleExport` (`web/src/components/GrafanaDashboardList.tsx:139-153`) downloads the file and reports success: the user gets `<uid>.json` containing only `{"uid": "..."}` plus an "exported" toast, where the real data source would have reported the failure through the page's existing `grafana.exportFailed` branch. ### Steps to Reproduce Reproduced by a unit test against `web/src/services/grafanaService.ts` in mock mode: 1. `exportGrafanaDashboard('nope')` — a uid that is not in `mockGrafanaDashboards`. 2. The promise resolves with a blob whose content is `{"uid": "nope"}`; nothing reports the failure. The same call against the real data source rejects with `Grafana dashboard not found: nope`. ### What Did You Expect to See? The demo export should fail for an unknown uid the way the endpoint does (404 "Grafana dashboard not found: <uid>"), so the page shows the export failure instead of a successful download of a stub. ### What Did You See Instead? A resolved blob containing only the requested uid, and `grafana.exported` reported as success. ### Additional Context - A fix with a regression test follows in a pull request. - The case is pinned by a unit test that fails without the fix: `AssertionError: promise resolved "Blob{ …(1) }" instead of rejecting`. ### 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]
