Skip to content

fix(mcp): keep MCP env a writable map when JSON is null - #332

Merged
BaaRai merged 1 commit into
BaaRai:mainfrom
Coff0xc:fix/mcp-null-env
Nov 18, 2026
Merged

BaaRai merged 1 commit into
BaaRai:mainfrom
Coff0xc:fix/mcp-null-env

Conversation

@Coff0xc

@Coff0xc Coff0xc commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

A stored MCP env of JSON null unmarshals to a nil map. syncBrowserMCPProxy then writes NODE_EXTRA_CA_CERTS when traffic capture is on, which panics (assignment to entry in nil map). The same call runs from NewManager, so a bad row plus capture-on becomes a crash loop.

decodeStrMap now always returns a writable map.

Tested: go test ./server -run TestDecodeStrMapJSONNull pass.

json.Unmarshal of JSON null into a map yields nil. syncBrowserMCPProxy
then assigned NODE_EXTRA_CA_CERTS under traffic capture and panicked,
including during NewManager on every restart once that row was stored.
Copilot AI balanced review requested due to automatic review settings November 18, 2026 11:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@BaaRai BaaRai left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Reviewed: JSON null previously left a nil map, and the first env[...] = ... write panicked. Returning a writable map for null, empty and invalid input is the right fix, and the test covers all three. Thanks.

@BaaRai
BaaRai merged commit 04964ac into BaaRai:main Nov 18, 2026
6 checks passed
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.

3 participants