Skip to content

fix: correct children items schema in POST /v1/pages to use blockObjectRequest ref#242

Open
4444J99 wants to merge 1 commit into
makenotion:mainfrom
4444J99:fix/issue-82-children-schema-type
Open

fix: correct children items schema in POST /v1/pages to use blockObjectRequest ref#242
4444J99 wants to merge 1 commit into
makenotion:mainfrom
4444J99:fix/issue-82-children-schema-type

Conversation

@4444J99

@4444J99 4444J99 commented Mar 28, 2026

Copy link
Copy Markdown

Summary

The OpenAPI spec for POST /v1/pages declares children.items as {"type": "string"}, while the equivalent PATCH /v1/blocks/{block_id}/children endpoint correctly uses {"$ref": "#/components/schemas/blockObjectRequest"}. This inconsistency causes MCP clients to treat block objects as plain strings, producing "Expected object, received string" validation errors when creating pages with content blocks.

Root cause: A single incorrect type declaration in scripts/notion-openapi.json at the POST /v1/pages endpoint's children property.

Fix: Replace {"type": "string"} with {"$ref": "#/components/schemas/blockObjectRequest"} to match the schema already used by PATCH /v1/blocks/{block_id}/children.

Changes

  • scripts/notion-openapi.json — Fix children.items type from string to $ref: blockObjectRequest in the POST /v1/pages schema
  • src/openapi-mcp-server/openapi/__tests__/parser.test.ts — Add tests verifying children items use $ref (not string) and both page-creation and block-append endpoints produce matching schema structures
  • src/openapi-mcp-server/mcp/__tests__/proxy.test.ts — Add test for full-array stringification deserialization (entire children array arriving as a JSON string)

Context

This interacts with two existing defenses already in the codebase:

  1. deserializeParams() in proxy.ts (from fix: handle double-serialized JSON parameters from MCP clients #180) handles runtime recovery when clients double-serialize parameters
  2. withStringFallback() in parser.ts wraps complex schemas with anyOf: [schema, {type: "string"}] to accept stringified input

This PR fixes the schema declaration so clients receive correct type information upfront, reducing reliance on the runtime workarounds above.

Fixes #82

Test plan

  • All 77 tests pass (74 existing + 3 new)
  • TypeScript type check passes (tsc --noEmit)
  • New parser test: verifies createPage and appendBlockChildren produce matching children schema structure
  • New parser test: verifies children.items is not typed as plain string
  • New proxy test: verifies full-array stringification (entire children as JSON string) is deserialized correctly

The OpenAPI spec for POST /v1/pages declared children.items as
{type: "string"} instead of {$ref: "#/components/schemas/blockObjectRequest"},
causing MCP clients to serialize block objects as strings rather than
structured objects. This is inconsistent with the PATCH /v1/blocks/{block_id}/children
endpoint which correctly uses the $ref.

Fixes makenotion#82

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@4444J99

4444J99 commented Apr 14, 2026

Copy link
Copy Markdown
Author

Gentle ping — this fixes the children.items schema type mismatch for POST /v1/pages (issue #82). All CI checks pass and three new tests are included. Let me know if anything needs adjusting.

@4444J99

4444J99 commented Apr 21, 2026

Copy link
Copy Markdown
Author

Hi — following up on this. The fix corrects the children.items schema in POST /v1/pages from {"type": "string"} to the proper $ref: blockObjectRequest, matching the existing schema on PATCH /v1/blocks/{block_id}/children. All 77 tests pass. Happy to rebase or adjust.

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.

Parameter serialization bug: Object parameters received as strings in create-pages and move-pages tools

1 participant