Skip to content

fix(schema): allow null system_fingerprint in OpenAI response#57

Open
ayo6706 wants to merge 1 commit intomainfrom
fix/openai
Open

fix(schema): allow null system_fingerprint in OpenAI response#57
ayo6706 wants to merge 1 commit intomainfrom
fix/openai

Conversation

@ayo6706
Copy link
Collaborator

@ayo6706 ayo6706 commented Feb 4, 2026

The OpenAI API sometimes returns system_fingerprint: null in the response (observed with gpt-5.1-2025-11-13). Our Zod schema only allowed string | undefined, causing a validation error:

APIResponseError: Invalid OpenAI API response structure: [
{
"code": "invalid_type",
"expected": "string",
"received": "null",
"path": ["system_fingerprint"],
"message": "Expected string, received null"
}
]

Solution

Updated OPENAI_RESPONSE_SCHEMA in
src/schemas/openai-responses.ts
to use .nullable().optional():

This allows:

undefined (field missing)
null (field explicitly null)
string (field with value)

Summary by CodeRabbit

  • Chores
    • Improved OpenAI API response handling to better manage edge cases in response validation and parsing.

OpenAI API can return `system_fingerprint: null` for some models,
but the Zod schema only accepted `string | undefined`. This caused
validation failures with an APIResponseError.
@coderabbitai
Copy link

coderabbitai bot commented Feb 4, 2026

📝 Walkthrough

Walkthrough

A schema field in the OpenAI responses schema was modified to accept null values. The system_fingerprint field changed from z.string().optional() to z.string().nullable().optional(), allowing it to be null, undefined, or absent.

Changes

Cohort / File(s) Summary
Schema Field Update
src/schemas/openai-responses.ts
Modified system_fingerprint field in OPENAI_RESPONSE_SCHEMA to accept null values in addition to being optional, changing validation from z.string().optional() to z.string().nullable().optional().

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 A whisker twitch, a schema shift,
Null values dance, a gentle gift,
The fingerprint may now be naught,
In optional realms, so wisely wrought!
One line changed, the code takes flight!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(schema): allow null system_fingerprint in OpenAI response' directly and clearly describes the main change: modifying the schema to accept null values for the system_fingerprint field.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/openai

Important

Action Needed: IP Allowlist Update

If your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:

  • 136.113.208.247/32 (new)
  • 34.170.211.100/32
  • 35.222.179.152/32

Reviews will stop working after February 8, 2026 if the new IP is not added to your allowlist.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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