Skip to content

[Routine - VT] fix(mcp): guard validate_json_structure against non-object array elements - #104

Merged
winterdrive merged 1 commit into
mainfrom
routine/vt-fix-validatejson-nonobject-element-260727
Aug 16, 2026
Merged

[Routine - VT] fix(mcp): guard validate_json_structure against non-object array elements#104
winterdrive merged 1 commit into
mainfrom
routine/vt-fix-validatejson-nonobject-element-260727

Conversation

@winterdrive

Copy link
Copy Markdown
Owner

Pre-flight Check

Changes

validate_json_structure iterates the parsed JSON array and immediately reads g.id / g.name / g.files off each element. If an element is null, a string, or a number (e.g. [null, {...}]), that throws a TypeError, which the outer try/catch swallows and reports back to the AI agent as a misleading "JSON parse error" for otherwise well-formed JSON.

This is the same bug class as the earlier merged fix "guard files iteration in validate_json_structure against undefined" (#82) — that one guarded g.files; this one guards g itself. Added a single early-continue guard:

if (!g || typeof g !== 'object') {
  errors.push(`Group[${i}] must be an object.`);
  continue;
}

Confirms this PR does not:

  • add/rename/remove any VS Code command registrations
  • add/rename/remove any contributed configuration keys in package.json
  • add, remove, or update any dependencies
  • modify the core tab-group serialization format or config storage/migration logic
  • touch package.json/package-lock.json version fields or CHANGELOG.md

Safety Verification

Commands run locally, all passed:

npx tsc -p ./                     # PASS, no errors
npm run test                      # tsc -p ./ && jest --runInBand → 31 suites / 203 tests passed
cd mcp-server && npx tsc --noEmit # PASS, no errors (mcp-server has no dedicated test script; same as the precedent fix #82)

CI / Release Gate Note

This is a daily routine Draft PR. Package version bump and CHANGELOG.md consolidation 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 for a routine PR, not a code validation failure.

Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com

…ents

A group entry that is null, a string, or a number (e.g. [null, {...}])
throws a TypeError on `g.id` inside the loop. That TypeError is
swallowed by the outer catch and reported back to the AI agent as a
misleading "JSON parse error" for otherwise-parseable JSON. Same bug
class as the earlier `g.files` undefined-iteration guard (#82), just
for the element itself.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@winterdrive
winterdrive marked this pull request as ready for review August 16, 2026 15:30
@winterdrive
winterdrive merged commit e29430e into main Aug 16, 2026
6 checks passed
@winterdrive winterdrive mentioned this pull request Aug 16, 2026
2 tasks
winterdrive added a commit that referenced this pull request Aug 16, 2026
Pre-release batch (odd minor) bundling 11 routine bug-fix PRs (#104-#109,
#111-#115) plus a dependabot dependency bump (#110), all independently
reviewed before merge.
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.

1 participant