Skip to content

refactor(config): sanitize string[] fields at readConfig boundary (#1395)#1396

Merged
esengine merged 1 commit into
mainfrom
refactor/config-zod-validation
May 20, 2026
Merged

refactor(config): sanitize string[] fields at readConfig boundary (#1395)#1396
esengine merged 1 commit into
mainfrom
refactor/config-zod-validation

Conversation

@esengine

Copy link
Copy Markdown
Owner

Summary

  • Moves 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 the readConfig() boundary.
  • New sanitizeStringArrayField filters non-string items out of mcp, mcpDisabled, recentWorkspaces, skills.paths. One console.warn per affected field names the file path + dropped count, so the user isn't surprised by partial config.
  • Removes the now-dead defenses: the .filter(typeof === "string") in emitMcpSpecs, the typeof ternaries in context-panel.tsx / settings.tsx, and the non-string-stringify branch in summarizeMcpSpec's catch. summarizeMcpSpec no longer needs to be exported.
  • Test file renamed mcp-desktop-react31.test.tsconfig-sanitize-string-arrays.test.ts and rewritten against readConfig (where the validation actually lives now).

Test plan

Closes #1395

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
@esengine esengine merged commit e5580e4 into main May 20, 2026
4 checks passed
@esengine esengine deleted the refactor/config-zod-validation branch May 20, 2026 07:16
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
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.

refactor(config): validate readConfig() output with zod (follow-up to #1394)

1 participant