Skip to content

fix(chat): guard prompts array before mapping in ToolsPopover#3081

Open
guitavano wants to merge 1 commit intomainfrom
fix/tools-popover-prompts-map-crash
Open

fix(chat): guard prompts array before mapping in ToolsPopover#3081
guitavano wants to merge 1 commit intomainfrom
fix/tools-popover-prompts-map-crash

Conversation

@guitavano
Copy link
Copy Markdown
Contributor

@guitavano guitavano commented Apr 9, 2026

Summary

  • Replaces data?.prompts ?? [] with Array.isArray(data?.prompts) ? data.prompts : [] in ToolsPopover
  • Prevents TypeError: I.map is not a function crash when the production virtual MCP endpoint returns a non-array value for prompts
  • The ?? operator only catches null/undefined — any other non-array shape (like an empty object) slips through and explodes on .map

Root cause

When a vir_* virtual MCP endpoint is used (instead of a direct conn_* connection), the production server can return a different response shape for prompts/list where prompts is not an array. Locally this does not reproduce because the local virtual MCP returns a proper array or nothing at all.

Test plan

  • Open the chat Tools popover and expand the Prompts submenu — no crash
  • Verify prompts still list correctly when the endpoint returns a valid array
  • Verify no crash when the endpoint returns {}, null, or undefined for prompts

Made with Cursor


Summary by cubic

Guard prompts before mapping in ToolsPopover to prevent a chat crash when the production virtual MCP endpoint returns a non-array prompts value. Replaces data?.prompts ?? [] with Array.isArray(data?.prompts) ? data.prompts : [] so non-array shapes don’t break .map.

Written for commit b6838e1. Summary will update on new commits.

Replaces `?? []` with `Array.isArray()` to prevent a crash when the
production virtual MCP endpoint returns a non-array value for `prompts`
(e.g. `{}`). The nullish coalescing operator only catches null/undefined,
so any other non-array shape slipped through and caused
`TypeError: I.map is not a function`.

Made-with: Cursor
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

🧪 Benchmark

Should we run the Virtual MCP strategy benchmark for this PR?

React with 👍 to run the benchmark.

Reaction Action
👍 Run quick benchmark (10 & 128 tools)

Benchmark will run on the next push after you react.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

Release Options

Suggested: Patch (2.250.1) — based on fix: prefix

React with an emoji to override the release type:

Reaction Type Next Version
👍 Prerelease 2.250.1-alpha.1
🎉 Patch 2.250.1
❤️ Minor 2.251.0
🚀 Major 3.0.0

Current version: 2.250.0

Note: If multiple reactions exist, the smallest bump wins. If no reactions, the suggested bump is used (default: patch).

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant