Skip to content

fix(zod): sanitize extracted definition refs#1903

Merged
HAYDEN-OAI merged 4 commits into
openai:mainfrom
FU-max-boop:fix/web-search-open-page-action-types
Jun 24, 2026
Merged

fix(zod): sanitize extracted definition refs#1903
HAYDEN-OAI merged 4 commits into
openai:mainfrom
FU-max-boop:fix/web-search-open-page-action-types

Conversation

@FU-max-boop

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

Summary

  • normalize whitespace to _ when zod v3 schemas extract reused definitions to root refs
  • keep $ref values and definitions keys aligned after normalization
  • add a regression test for reused schemas under property names containing spaces

Why

zodResponseFormat can currently produce $ref values such as #/definitions/example-scope_properties_group_properties_Thing With Spaces. Those literal spaces can be rejected by the API and make the generated schema harder to consume.

Fixes #1679.

Testing

  • npx -y yarn@1.22.22 test tests/helpers/zod.test.ts --runInBand
  • npx -y yarn@1.22.22 prettier --check src/_vendor/zod-to-json-schema/parseDef.ts tests/helpers/zod.test.ts
  • npx -y yarn@1.22.22 eslint src/_vendor/zod-to-json-schema/parseDef.ts tests/helpers/zod.test.ts
  • npx -y yarn@1.22.22 build
  • git diff --check

@FU-max-boop FU-max-boop requested a review from a team as a code owner May 28, 2026 22:45

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6ad9563f79

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/_vendor/zod-to-json-schema/parseDef.ts Outdated
@HAYDEN-OAI

Copy link
Copy Markdown
Contributor

@FU-max-boop thanks for tracking this down and for sticking with the collision-safe ref handling. appreciate your patience while we brought the branch current and worked through the recursive-schema edge case. merging now! 💚

@HAYDEN-OAI HAYDEN-OAI merged commit 6ef2111 into openai:main Jun 24, 2026
10 checks passed
@stainless-app stainless-app Bot mentioned this pull request Jun 24, 2026
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.

zodResponseFormat emits $ref values and definition keys with spaces

2 participants