fix(mcp): surface real error in collection validation catch#383
Open
mvanhorn wants to merge 1 commit into
Open
fix(mcp): surface real error in collection validation catch#383mvanhorn wants to merge 1 commit into
mvanhorn wants to merge 1 commit into
Conversation
The catch block in handlers.ts interpolated `err.message || err`, which falls through to default object stringification when the thrown value is a plain object without a `.message` property. The user-facing MCP response ended up reading "Error validating collection creation: [object Object]". Replace the antipattern with a `formatValidationError` helper that tries `err.message`, then nested `response.data.message` and `response.data.detail`, then `response.statusText`, then JSON.stringify, and only falls back to String(err) when nothing usable can be extracted. Apply the helper to the same antipattern at the other catch sites in the file (sync, fallback query, snapshot delete, indexing dispatcher). `npx tsc --noEmit` on packages/mcp passes after this change. Fixes zilliztech#215
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.
Summary
Replace the
err.message || errinterpolation in the MCP catch blocks with a smallformatValidationErrorhelper so users see the actual error from Zilliz / Milvus instead of[object Object].Why this matters
Issue #215 reports
Error validating collection creation: [object Object]fromindex_codebase. Multiple users in the thread confirm the same opaque message (@DeadManPoe on Rust, @Wazabit on a NestJS TS codebase, @PeterSenyszyn, @mahmoudnaif, @KrustyHack). @PeterSenyszyn traced the root cause: Zilliz Cloud free tier caps collections at 5 per cluster, and the create call rejects past that.The catch at
packages/mcp/src/handlers.ts:463interpolated${validationError.message || validationError}. WhenvalidationErroris a plain object without.message, the||fallback returns the object itself and template coercion produces[object Object]. The same antipattern repeats at four other catch sites in the file (cloud sync description, fallback query, snapshot delete, indexing dispatcher).formatValidationErrortries, in order:err.message(when it's a non-empty string and not literally[object Object])err.response.data.messageerr.response.data.detailerr.response.statusTextJSON.stringify(err)(when the result is not{}ornull)String(err)(final fallback)This turns the Zilliz collection-limit error and similar response-bearing errors into a readable message at every existing catch site without changing the surrounding flow.
checkCollectionLimititself is not modified; this is purely a presentation fix.Testing
npx tsc --noEmitonpackages/mcppasses.Fixes #215