[Routine - VT] fix(mcp): guard files iteration in validate_json_structure against undefined#82
Draft
winterdrive wants to merge 1 commit into
Draft
Conversation
…defined 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 <noreply@anthropic.com>
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.
1. Pre-flight Check
Open PRs checked (all Draft, all CLEAN merge status):
routine/vt-fix-autogroup-bookmarks-260708— touchessrc/core/AutoGrouper.ts,src/test/unit/autoGrouperBookmarks.test.tsroutine/vt-fix-jumptobookmark-clamp-260707— touchessrc/commands.tsroutine/vt-fix-filemanager-relpath-260706— touchessrc/core/FileManager.ts,src/test/unit/fileManagerRelpath.test.tsroutine/vt-fix-bookmark-stale-groupidx-260703— touchessrc/provider.tsroutine/vt-fix-treeview-listener-disposal-260702— touchessrc/extension.tsrelease/0.7.6-260701— release PR (non-code-diff concern)This PR touches only
mcp-server/src/server.ts, which is not modified by any of the above. No overlap.2. Changes
validate_json_structure(the MCP tool AI agents are told to call before any direct write to.vscode/virtualTab.json) validates each group's optionalfilesfield with:Since
filesis a legitimately optional field (per the tool's own JSON schema), any group without afileskey hits theelsebranch and doesfor (const f of undefined), throwingTypeError: undefined is not iterable. That exception is swallowed by the handler's outertry/catchand reported back to the AI agent as"JSON parse error: ... is not iterable"— a misleading false negative for perfectly valid, syntactically correct JSON.Fix: only iterate
g.fileswhen it is actually an array (else if (Array.isArray(g.files))), matching the same predicate already used for the invalid-type check.Confirms this PR does not modify commands, contributed configuration keys, dependencies, or the tab-group serialization/storage format. No
package.json/package-lock.json/CHANGELOG.mdchanges.3. Safety Verification
Commands run locally, all passed:
npx tsc -p ./— no errorsnpx tsc -p ./mcp-server— no errorsnpm run test(tsc -p ./ && jest --runInBand) — 25 suites / 175 tests passednpm run build:mcp(esbuild bundle sanity check) — succeeded[{ "id": "g1", "name": "Empty Group" }](nofileskey) — before the fix this throws; after the fix it returns{ "valid": true, "errors": [], "warnings": [] }No
lintorformat:checknpm scripts exist in this repo, so those steps were skipped per the routine-task instructions.4. CI / Release Gate Note
This is a daily routine Draft PR. Package version bump and
CHANGELOG.mdconsolidation are intentionally deferred to the weekend release/integration PR. If CI fails solely due to the repository's version-bump release gate, that is expected release-readiness behavior, not a code validation failure.