Zod => JSONSchema compilation produces infinitely recursive schemas when using transforms #1009
Closed
1 task done
Labels
bug
Something isn't working
Confirm this is a Node library issue and not an underlying OpenAI API issue
Describe the bug
When using a
zodFunction
with a zod schema that has multiple references to an object with a transformed property, the produced JSON schema is infinitely recursive and invalid. It causes the OpenAI API to 500 when requested.I believe both of these conditions are necessary to trigger the bug:
.transform
attached to itThe produced JSONSchema ends up looking like this:
which is self-referential and broken, sad.
To Reproduce
Here's a test that reproduces the error:
Code snippets
Here's what the problematic compiled JSONSchema looks like:
OS
macOS
Node version
node v22.2.0
Library version
openai v4.56.0
The text was updated successfully, but these errors were encountered: