fix(schema): allow null system_fingerprint in OpenAI response#57
fix(schema): allow null system_fingerprint in OpenAI response#57
Conversation
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.
📝 WalkthroughWalkthroughA schema field in the OpenAI responses schema was modified to accept null values. The Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Important Action Needed: IP Allowlist UpdateIf your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:
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. Comment |
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