Skip to content

fix: preserve referenced schema definitions - #5588

Merged
zzstoatzz merged 4 commits into
PrefectHQ:mainfrom
lux-liang:fix/preserve-referenced-schema-definitions
Nov 10, 2026
Merged

zzstoatzz merged 4 commits into
PrefectHQ:mainfrom
lux-liang:fix/preserve-referenced-schema-definitions

Conversation

@lux-liang

Copy link
Copy Markdown
Contributor

Description

Fixes #5587.

Renaming a tool could remove definitions still referenced by its input schema: #/$defs/Display~1name lost Display/name, and #/$defs/Envelope/properties/name lost Envelope. Schema compression now decodes the fragment and JSON Pointer token before tracking the owning definition, preserving valid references while continuing to prune unused definitions. This follows RFC 6901's pointer decoding rules.

For example, this schema stays resolvable after Tool.from_tool(tool, name="renamed"):

{
  "type": "object",
  "properties": {"value": {"$ref": "#/$defs/Display~1name"}},
  "$defs": {"Display/name": {"type": "string"}}
}

AI assistance was used for investigation, implementation, independent review, and local validation. Generated with Codex.

Contribution type

  • Bug fix (simple, well-scoped fix for a clearly broken behavior)
  • Documentation improvement
  • Enhancement

Checklist

  • This PR addresses an existing issue (or fixes a self-evident bug)
  • I have read CONTRIBUTING.md
  • I have added tests that cover my changes
  • I have run uv run prek run --all-files and all checks pass
  • I have self-reviewed my changes
  • If I used an LLM, it followed the repo's contributing conventions (not generic output)

Local full-suite validation remains limited by Windows symlink permissions and subprocess/worker failures observed during unchanged-baseline comparisons; Linux CI is pending.

@github-actions

This comment has been minimized.

@marvin-context-protocol marvin-context-protocol Bot added the bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality. label Oct 8, 2026

HootRock commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Reviewed 022be008 against 5baeacfe. The URI-fragment percent decoding and JSON Pointer token unescaping follow RFC 6901 sections 6 and 4, including the ~1 then ~0 order.

All 78 targeted tests pass. An independent 42-case legal-schema matrix passes 42/42 on head versus 2/42 on base, covering escaped names, Unicode, empty keys, nested pointers, arrays and transitive definitions. Boolean leaves, recursive definitions, input immutability and the real FunctionTool-to-transformed-tool path also passed.

I found no consequential defect in the scoped change. A broader tool-transform run stopped at a Windows socket-fixture timeout whose cause remains unresolved, so this does not establish a full-suite pass. Full hooks were not reproduced; assignment and upstream code CI remain pending.

@fastmcp-triage-reviewer fastmcp-triage-reviewer Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review by the FastMCP triage reviewer bot.

Fixes the four reported reference forms. One gap remains in the same contract: a $ref of #%2F$defs%2FKeep points at an existing definition once the fragment is percent-decoded, but that definition still gets pruned because the #/ prefix check runs before decoding.

Please decode the whole fragment before checking the leading separator, and add a regression comparing #%2F$defs%2FKeep with #/$defs/Keep. _resolve_local_ref has the same ordering issue.

Checks

Reviewed at 022be00. The four reported forms fail on main and pass here. Ordinary references, unused-definition pruning and input immutability behave the same on both.


Generated by Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zzstoatzz and others added 2 commits November 10, 2026 13:37
…ed-schema-definitions

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zzstoatzz
zzstoatzz merged commit 5f1d152 into PrefectHQ:main Nov 10, 2026
25 checks passed
zzstoatzz added a commit that referenced this pull request Nov 10, 2026
* Revert "fix: preserve referenced schema definitions (#5588)"

This reverts commit 5f1d152.

* Revert "fix(server): rebuild tool argument errors instead of echoing pydantic's (#6107)"

This reverts commit 8fba5f7.

* Revert "Advertise the MCP Apps extension only when the server serves an app (#5062)"

This reverts commit b89222b.

* Revert "fix(tasks): retain results after tool removal (#5507)"

This reverts commit 711575a.

* Revert "fix(client): Prevent stale ClientGroup refreshes from replacing newer routes (#5543)"

This reverts commit 365d5d2.

* Revert "fix(prompts): honor field aliases when rendering prompts (#5836)"

This reverts commit a450fd8.

* Revert "Stop FastMCP callable caches from retaining dropped tools (#6147)"

This reverts commit 713f247.

* Revert "feat(auth): Add KeystoneTokenVerifier (#6264)"

This reverts commit c33f3de.

* Revert "fix(json-schema): keep x-unsupported-pattern when a format is set (#5731)"

This reverts commit dc9849d.

* Revert "Roll back the tool stamp when a tool registration is rejected (#5798)"

This reverts commit d6566c5.

* Revert "fix(server): validate cursors when pagination is disabled (#6045)"

This reverts commit 4917bee.

* Revert "Keep constraints on scalar schema references (#6041)"

This reverts commit e5176c9.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality. bypass-issue-check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tool renaming drops definitions referenced by escaped JSON Pointers

3 participants