extract_servers raises on a non-dict server value — unhandled crash on load, and it makes the schema lint unreachable #72
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
extract_servers()doesdict(data)on every server value without checking the shape:A config that is perfectly valid JSON but has a server whose value isn't an object blows up:
(Reproduced against
cd2ac2f.)Why it's a crash, not a handled error
In
MainWindow._load_profile, thetry/exceptonly wraps the parse. Strict parse succeeds here — the JSON is well-formed — so the repair path is never entered, andcore.extract_servers(self.full_config)(bcc.py ~L1944) runs outside any handler. Result: unhandled traceback, andself.current_profilehas already been assigned whileself.servershas not — the window is left in a half-loaded state.Why it also defeats #54
lint_server()already has the right warnings for malformed shapes, but it can never fire on this class of problem: the load crashes before lint ever sees the entry. The structural-lint feature is unreachable for the single most-likely hand-edit mistake.This also cuts against the project's core premise — a file that is valid JSON but structurally off should be reported and repaired, never a hard failure.
Suggested fix
extract_servers: coerce non-dict values to{}(or keep the raw value on the entry) rather than callingdict()on them, and letlint_serversurface the warning.lint_serverbranch for "server definition is not an object" so the user gets told which entry is malformed.extract_serversinside the load try/except as defence in depth.Tests
{"mcpServers": {"foo": "not-a-dict"}}and the int/list/None variants load without raising and produce a lint warning namingfoo.