Skip to content

fix(mcp): handle non-string metadata in cloud sync handler#270

Open
DelphiaDan wants to merge 1 commit intozilliztech:masterfrom
DelphiaDan:fix/metadata-parsing-cloud-sync-zilliz
Open

fix(mcp): handle non-string metadata in cloud sync handler#270
DelphiaDan wants to merge 1 commit intozilliztech:masterfrom
DelphiaDan:fix/metadata-parsing-cloud-sync-zilliz

Conversation

@DelphiaDan
Copy link

@DelphiaDan DelphiaDan commented Feb 18, 2026

Summary

  • The cloud sync handler queries a collection for its first document's metadata to extract the codebasePath
  • Depending on the vector DB backend, metadata may already be a parsed JS object rather than a JSON string
  • JSON.parse() is called unconditionally on line 86, which throws when the value is not a string
  • The catch block logs a warning and the codebase path never registers, so search_code reports "codebase not indexed" even after successful indexing

Fix

Add a type guard to only parse when metadata is actually a string:

const metadata = typeof metadataStr === 'string' ? JSON.parse(metadataStr) : metadataStr;

Fixes #226

LanceDB returns metadata as a parsed JS object, but the cloud sync
handler calls JSON.parse() unconditionally. This throws on non-string
input, causing the codebase path to never register — so search_code
reports "codebase not indexed" after successful indexing.

Add a type guard to only parse when metadata is a string.

Fixes zilliztech#226
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.

claude-context MCP search_code fails despite successful indexing

1 participant