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

   ## Summary
   - In the AI tool runner's `loadTools()`, treat a non-array tool catalog 
payload as an empty catalog (`Array.isArray` guard) before setting state and 
auto-selecting the first tool
   - Add a regression test: a `null` catalog payload leaves the tool modal open 
with an empty catalog instead of surfacing the "failed to load" error path
   
   ## Why
   `listTools()` returns `res.data.data`, so the wire can deliver anything 
(e.g. `null` or an object) even though the TypeScript type says `McpTool[]`. 
The page dereferenced the payload with `availableTools.find(...)`: a `null` 
catalog threw a `TypeError` that fell into the `catch` branch, showing "AI 
工具目录加载失败" (catalog load failed) even though the request succeeded, and the tool 
modal was left in the error state for no recoverable reason.
   
   ## Testing
   - `./node_modules/.bin/vitest run src/pages/ai/__tests__/AiPage.test.tsx` → 
14 passed (1 new; verified it fails with the pre-fix payload handling)
   - `./node_modules/.bin/tsc --noEmit` → clean
   - `./node_modules/.bin/eslint src/pages/ai/index.tsx 
src/pages/ai/__tests__/AiPage.test.tsx` → 0 errors
   


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