Skip to content

fix(pydantic): decode escaped local JSON schema references - #3602

Draft
weivwang wants to merge 1 commit into
openai:mainfrom
weivwang:fix/decode-json-pointer-refs
Draft

fix(pydantic): decode escaped local JSON schema references#3602
weivwang wants to merge 1 commit into
openai:mainfrom
weivwang:fix/decode-json-pointer-refs

Conversation

@weivwang

Copy link
Copy Markdown
  • I understand that this repository is auto-generated and my pull request may not be merged

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 $ref and uses each raw segment as a dictionary key. Definitions containing /, ~, spaces, or other escaped characters therefore fail with KeyError, 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 $ref handling. The modified source is under src/openai/lib/, which CONTRIBUTING.md identifies as outside the generated SDK surface.

Validation:

  • pytest -q tests/lib/test_pydantic.py — 5 passed
  • ruff check src/openai/lib/_pydantic.py tests/lib/test_pydantic.py
  • ruff format --check src/openai/lib/_pydantic.py tests/lib/test_pydantic.py
  • git diff --check

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.

1 participant