You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#1394 fixed the React #31 crash by adding 4 layers of defensive typeof checks downstream of readConfig(). The root cause is upstream: src/config.ts:330 does JSON.parse(raw) as ReasonixConfig with no runtime validation, so cfg.mcp (typed string[]) can contain objects, numbers, etc. from a hand-edited config.json.
Per repo conventions, boundary input should be validated with zod and downstream code should trust the types. Right now we have it backwards.
Scope
Define a zod schema for ReasonixConfig (or at least the fields most exposed to hand-editing: mcp, mcpDisabled, skills.paths, pricingOverride, ...).
Run it in readConfig(). On invalid item:
drop the item from the returned config
log a clear console.warn naming the file path, field, and bad value (so the user knows their config was partially ignored — not silently swallowed)
the typeof s.summary === "string" ? ... : "[invalid]" ternaries in desktop/src/ui/context-panel.tsx and desktop/src/ui/settings.tsx
the .filter((raw): raw is string => typeof raw === "string") in emitMcpSpecs becomes unnecessary once the schema guarantees string[]
the catch-block stringification in summarizeMcpSpec can stay (it's defending against malformed strings, not non-strings)
Keep the regression test in tests/mcp-desktop-react31.test.ts; add a new test that a malformed config.jsonmcp entry is dropped + warned at read time.
Why not just leave it
The current state has the validation in 4 places. Any new field added to config that's hand-editable will repeat the same pattern unless we move it to the boundary. Code review will keep hitting "where do we validate this" without a clear answer.
Follow-up to #1394 / #1295.
#1394 fixed the React #31 crash by adding 4 layers of defensive
typeofchecks downstream ofreadConfig(). The root cause is upstream:src/config.ts:330doesJSON.parse(raw) as ReasonixConfigwith no runtime validation, socfg.mcp(typedstring[]) can contain objects, numbers, etc. from a hand-editedconfig.json.Per repo conventions, boundary input should be validated with zod and downstream code should trust the types. Right now we have it backwards.
Scope
ReasonixConfig(or at least the fields most exposed to hand-editing:mcp,mcpDisabled,skills.paths,pricingOverride, ...).readConfig(). On invalid item:console.warnnaming the file path, field, and bad value (so the user knows their config was partially ignored — not silently swallowed)typeof s.summary === "string" ? ... : "[invalid]"ternaries indesktop/src/ui/context-panel.tsxanddesktop/src/ui/settings.tsx.filter((raw): raw is string => typeof raw === "string")inemitMcpSpecsbecomes unnecessary once the schema guaranteesstring[]summarizeMcpSpeccan stay (it's defending against malformed strings, not non-strings)tests/mcp-desktop-react31.test.ts; add a new test that a malformedconfig.jsonmcpentry is dropped + warned at read time.Why not just leave it
The current state has the validation in 4 places. Any new field added to config that's hand-editable will repeat the same pattern unless we move it to the boundary. Code review will keep hitting "where do we validate this" without a clear answer.