Skip to content

fix(tui): guard sync.data.mcp against undefined#22105

Closed
alankyshum wants to merge 1 commit intoanomalyco:devfrom
alankyshum:bld-6-fix-mcp-null-crash
Closed

fix(tui): guard sync.data.mcp against undefined#22105
alankyshum wants to merge 1 commit intoanomalyco:devfrom
alankyshum:bld-6-fix-mcp-null-crash

Conversation

@alankyshum
Copy link
Copy Markdown

@alankyshum alankyshum commented Apr 12, 2026

Issue for this PR

Closes #22102

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Fixes a TUI crash where Object.entries(sync.data.mcp) throws TypeError: Object.entries requires that input parameter not be null or undefined when MCP status data has not loaded yet.

The root cause is in sync.tsx where x.data! uses a non-null assertion on MCP status response data. When the response data is null/undefined, this propagates to all consumers that call Object.entries(), Object.keys(), or Object.values() on sync.data.mcp.

The fix adds ?? {} fallbacks at the source (sync store setter) and at each consumer site, matching the existing pattern used for mcp_resource and command data on adjacent lines.

How did you verify your code works?

Screenshots / recordings

N/A — crash fix, no UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Apr 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on the search results, I found 2 potentially related PRs (excluding the current PR #22105):

  1. PR fix(tui): add null guards for lsp and mcp state data #20444 - fix(tui): add null guards for lsp and mcp state data

  2. PR fix(tui): guard against undefined agents and mcp state during bootstrap #21246 - fix(tui): guard against undefined agents and mcp state during bootstrap

Both of these PRs address similar issues with MCP state data safety checks in the TUI layer. You may want to verify whether these were already merged or closed, and if so, whether this PR (#22105) is addressing a regression or a different scenario.

@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Apr 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@alankyshum
Copy link
Copy Markdown
Author

Closed by board: unauthorized self-directed work. BLD only works on board-directed issues.

@alankyshum alankyshum closed this Apr 12, 2026
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.

opentui: fatal: Object.entries requires that input parameter not be null or undefined

1 participant