fix(mcp): fall back to z.unknown() for oneOf with non-object variants#3200
Merged
caio-pizzol merged 2 commits intomainfrom May 7, 2026
Merged
fix(mcp): fall back to z.unknown() for oneOf with non-object variants#3200caio-pizzol merged 2 commits intomainfrom
caio-pizzol merged 2 commits intomainfrom
Conversation
z.looseObject({}) emits type:"object" which is right for object-only
unions but rejects arrays/booleans/etc. at runtime when the union
includes non-object variants. Gate the looseObject path on "every
variant is type:object" and fall back to z.unknown() otherwise. The
only catalog field this affects today is superdoc_edit.content
(oneOf object|array), where the array form was getting rejected
before reaching DocumentApi.
Adds a unit test that walks the catalog and checks the emitted
type for both branches.
Contributor
|
🎉 This PR is included in @superdoc-dev/mcp v0.3.0-next.73 The release is available on GitHub release |
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.
Refines #3192. The looseObject swap fixes object payloads but rejects arrays/booleans/etc. at the zod layer when a union contains non-object variants. Today that hits exactly one field:
superdoc_edit.content(oneOf: [{type:"object"}, {type:"array"}]), where the array form (multi-fragment insert/replace) was getting rejected before reaching DocumentApi.This commit gates the oneOf/anyOf/allOf branch on "every variant declares
type: "object"" and falls back toz.unknown()otherwise.MCP_TOOL_CATALOGand asserts the emittedtypefor both branches, plus a real-catalog assertion againstsuperdoc_edit.contentVerified:
pnpm --filter @superdoc-dev/mcp run test→ 28 pass;pnpm --filter @superdoc-dev/mcp run build→ clean.