From ca97688fd1ba508cc893a016d0f7b24867c147aa Mon Sep 17 00:00:00 2001 From: winterdrive <90021888+winterdrive@users.noreply.github.com> Date: Thu, 9 Jul 2026 07:09:02 +0800 Subject: [PATCH] fix(mcp): guard files iteration in validate_json_structure against undefined Groups without a "files" key (a valid, optional field) hit the else branch's `for...of g.files`, throwing "undefined is not iterable". That TypeError was swallowed by the outer catch and reported back to the AI agent as a misleading "JSON parse error" for otherwise valid JSON. Co-Authored-By: Claude Sonnet 5 --- mcp-server/src/server.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mcp-server/src/server.ts b/mcp-server/src/server.ts index 212bccd..982ac03 100644 --- a/mcp-server/src/server.ts +++ b/mcp-server/src/server.ts @@ -597,7 +597,7 @@ export class VirtualTabsMCPServer { if (!g.name) { errors.push(`Group[${i}] missing "name".`); } if (g.files !== undefined && !Array.isArray(g.files)) { errors.push(`Group "${g.name ?? i}" has invalid "files" (expected array or undefined).`); - } else { + } else if (Array.isArray(g.files)) { for (const f of g.files) { if (path.isAbsolute(f)) { errors.push(`Group "${g.name}": absolute path detected: "${f}". Must be workspace-relative.`);