refactor(config): sanitize string[] fields at readConfig boundary (#1395)#1396
Merged
Conversation
readConfig() previously cast JSON.parse output to ReasonixConfig with no runtime validation. Hand-edited config.json could put objects, numbers, or null into fields typed as string[] (mcp, mcpDisabled, recentWorkspaces, skills.paths), corrupting downstream consumers — see #1295 / #1394 where non-string mcp items reached JSX and crashed the desktop tools panel. Sanitize these fields once at the boundary: drop non-string items, warn once per field with the file path and dropped count. Remove the now-dead downstream defenses (#1394's filter in emitMcpSpecs, typeof ternaries in context-panel.tsx and settings.tsx, summarizeMcpSpec's non-string catch). Closes #1395
ChasLui
pushed a commit
to ChasLui/DeepSeek-Reasonix
that referenced
this pull request
May 23, 2026
…engine#1396) readConfig() previously cast JSON.parse output to ReasonixConfig with no runtime validation. Hand-edited config.json could put objects, numbers, or null into fields typed as `string[]` (mcp, mcpDisabled, recentWorkspaces, skills.paths), corrupting downstream consumers — see esengine#1295 / esengine#1394 where non-string mcp items reached JSX and crashed the desktop tools panel. - New `sanitizeStringArrayField` in `src/config.ts` drops non-string items at the boundary and warns once per field with the file path + dropped count. - Removes the now-dead downstream defenses (esengine#1394's filter in `emitMcpSpecs`, `typeof` ternaries in `context-panel.tsx` / `settings.tsx`, `summarizeMcpSpec`'s non-string catch). `summarizeMcpSpec` no longer needs to be exported. - Test file renamed to `config-sanitize-string-arrays.test.ts` and rewritten against `readConfig` (where the validation actually lives). Closes esengine#1395
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
string[]field validation from 4 downstream defensive sites (added in fix(desktop): prevent React #31 when MCP config contains non-string items (#1295) #1394) up to thereadConfig()boundary.sanitizeStringArrayFieldfilters non-string items out ofmcp,mcpDisabled,recentWorkspaces,skills.paths. Oneconsole.warnper affected field names the file path + dropped count, so the user isn't surprised by partial config..filter(typeof === "string")inemitMcpSpecs, thetypeofternaries incontext-panel.tsx/settings.tsx, and the non-string-stringify branch insummarizeMcpSpec's catch.summarizeMcpSpecno longer needs to be exported.mcp-desktop-react31.test.ts→config-sanitize-string-arrays.test.tsand rewritten againstreadConfig(where the validation actually lives now).Test plan
npm run verify(build + lint + typecheck + 3388 tests) passes locallymcpfield with object items now produces[<string items only>]fromreadConfig— the original Desktop: 配置 MCP Server 后 tools 面板报 React #31 错误 #1295 crash class can't recurCloses #1395