Fix $ref output schema object detection regression#3420
Conversation
🤖 Generated with GPT-5.2-Codex
|
/marvin fix static analysis |
|
Claude finished @jlowin's task in 1m 17s —— View job Fixed static analysis
The Marvin Context Protocol | Type Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not. |
Test Failure AnalysisSummary: The Root Cause: In # line 289 — invalid
alias_type = TypeAliasType("AliasType", Literal["foo", "bar"])
# variable: alias_type ^ name: AliasType (mismatch!)Suggested Solution: Fix the variable name to match the In alias_type = TypeAliasType("AliasType", Literal["foo", "bar"])to: AliasType = TypeAliasType("AliasType", Literal["foo", "bar"])and update any references to Detailed AnalysisFailing checkOther checks
Related Files
|
Co-authored-by: Jeremiah Lowin <jlowin@users.noreply.github.com> 🤖 Generated with Claude Code
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5257deeaa4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| definition_name = ref.removeprefix("#/$defs/") | ||
| definitions = root_schema.get("$defs") | ||
| if not isinstance(definitions, dict): | ||
| return False | ||
|
|
||
| target_schema = definitions.get(definition_name) |
There was a problem hiding this comment.
Resolve escaped JSON-pointer tokens in $defs refs
The new $ref resolver assumes the definition key is the raw suffix after #/$defs/, but JSON Pointer escapes / and ~ as ~1/~0 (and can include deeper paths), so refs like #/$defs/A~1B or #/$defs/Outer/$defs/Inner won’t resolve even when they point to object schemas. In those cases _is_object_schema returns False, which causes FastMCP to wrap an already-object output and change structured_content shape unexpectedly for valid schemas that previously passed object checks.
Useful? React with 👍 / 👎.
|
Auto-reviewed: all CI checks green, review comments addressed. Merging. |
Motivation
$refand$defsas an object, which causes non-object referenced schemas (for example Pydantic alias/enums) to be misclassified and skip wrapping. This can lead toToolResultruntimeValueErrorbecausestructured_contentmust be adict.#/$defs/...targets before deciding whether a schema is object-shaped.Description
_is_object_schemainsrc/fastmcp/tools/function_parsing.pyto accept optional_root_schemaand_seen_refsparameters and resolve local#/$defs/...references recursively instead of assuming$ref + $defsmeans an object.test_output_schema_wraps_non_object_ref_schemaintests/server/providers/local_provider_tools/test_output_schema.pywhich uses aTypeAliasType/Literalalias to ensure non-object$refschemas are wrapped (x-fastmcp-wrap-result) and runtimestructured_contentis a dict.Literal,TypeAliasType).Testing
uv syncsuccessfully to install dependencies.uv run pytest -n auto, which completed but reported unrelated failures in the container run (12failed,1error) that appear environment/timeout related and not caused by this change.uv run pytest tests/server/providers/local_provider_tools/test_output_schema.py, and all20tests passed.prekstatic hook runuv run prek run --all-filesfailed to initialize due to a network/git clone error (403) and could not complete.Codex Task