fix(pydantic): decode escaped local JSON schema references - #3602
Draft
weivwang wants to merge 1 commit into
Draft
fix(pydantic): decode escaped local JSON schema references#3602weivwang wants to merge 1 commit into
weivwang wants to merge 1 commit into
Conversation
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.
Changes being requested
Decode URI fragments and RFC 6901 escape sequences while resolving local JSON Schema references in the handwritten Pydantic helper.
resolve_ref()currently splits a local$refand uses each raw segment as a dictionary key. Definitions containing/,~, spaces, or other escaped characters therefore fail withKeyError, for example:{"$ref":"#/$defs/path~1to%20model~0v1"}The change decodes each segment after splitting it, then applies JSON Pointer's
~1→/and~0→~substitutions. Decoding after the split is important: a percent-encoded/belongs to the definition key and must not become an extra path segment.Two regressions cover both direct resolution and the real strict-schema inlining path with sibling properties.
Additional context & links
No matching issue or open PR was found for escaped local
$refhandling. The modified source is undersrc/openai/lib/, whichCONTRIBUTING.mdidentifies as outside the generated SDK surface.Validation:
pytest -q tests/lib/test_pydantic.py— 5 passedruff check src/openai/lib/_pydantic.py tests/lib/test_pydantic.pyruff format --check src/openai/lib/_pydantic.py tests/lib/test_pydantic.pygit diff --check