unbridled-41 opened a new pull request, #4241:
URL: https://github.com/apache/rocketmq-dashboard/pull/4241

   Fixes #4239.
   
   ## Problem / Evidence
   
   The instance create and edit dialogs swallow the server's error reason. 
`handleCreate` and `handleUpdate` in `web/src/pages/instance/index.tsx` catch 
request failures and show only the generic localized toasts 
(`instance.createFailed` → "添加实例失败,请稍后重试" / `instance.updateFailed` → 
"更新实例失败,请稍后重试"), while delete, batch-delete, and import on the same page use 
the in-file `describeApiError` helper to surface `response.data.message`.
   
   The dropped content matters: creating a duplicate name makes 
`InstanceService` throw `DuplicateInstanceNameException`, serialized by 
`GlobalExceptionHandler` as `{"code":400,"message":"Instance name already 
exists: <name>"}` — the user sees "添加实例失败,请稍后重试" instead. Reproduced 
deterministically by the two new regression tests, both failing before the fix 
(only the generic toast rendered; the server message never appeared).
   
   ## Root cause / Fix
   
   The create/update catch blocks predate (or were never included in) the 
`describeApiError` pattern the same file already uses for delete/import. Fix: 
`message.error(describeApiError(error, t('instance.createFailed')))` in 
`handleCreate` and the matching `describeApiError(error, 
t('instance.updateFailed'))` in `handleUpdate`. The antd field-validation 
early-return (`errorFields`) is untouched, so client-side validation errors 
still render as field-level messages.
   
   ## Priority & scoring
   
   PRIORITY 76 = impact 28 (duplicate names are the most common create failure; 
users cannot distinguish a naming conflict from a transient error) + blast 
radius 12 (every create and every update failure path on the instance 
lifecycle) + reproducibility 20 (deterministic: submit a duplicate name) + 
maintenance value 16 (adopts the helper pattern the same file already 
established). FIX_CONFIDENCE 97: one-line changes reusing an existing in-file 
helper; both regression tests fail red before and pass green after.
   
   ## Tests
   
   - New regressions in 
`web/src/pages/instance/__tests__/InstancePage.test.tsx`: `surfaces the server 
error reason when creating an instance fails` and `... when updating an 
instance fails` — mock the service to reject with `{ response: { data: { 
message: ... } } }`, submit, assert the server message renders and the generic 
toast does not. **Both red before the fix, both green after.**
   - `npx vitest run src/pages/instance/__tests__/InstancePage.test.tsx` → 
**25/25 passed** (23 pre-existing + 2 new).
   - Full web suite `npx vitest run` on this branch: **983 tests (981 
pre-existing + 2 new), 1 failure** in MetricsExplorer — a file this PR does not 
touch; re-run in isolation it passes **25/25** (the pre-existing parallel-load 
flakiness recorded in the repo baselines), so there are zero new failures.
   - `npx tsc --noEmit` clean; `npx eslint` on both changed files clean; `npm 
run build` succeeds.
   
   ## Risk
   
   Minimal. Failure toasts only ever become more specific: when the API 
response carries a message it is shown (matching delete/import behavior), 
otherwise the exact same generic localized fallback text renders. Success 
paths, validation paths, and the in-flight guard are unchanged.
   


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