fix: expose raw error messages and flatten tool schemas for OpenAI#1276
Conversation
Add rawMessage field to SanitizedError so the UI can display the original provider error beneath the translated hint, giving users more context when debugging failures.
…penAI Work around vercel/ai#7924 where z.discriminatedUnion() produces top-level oneOf schemas that OpenAI rejects. The middleware merges variant schemas into a single flat object before sending to the API.
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThe PR extends error handling across the chat feature by adding a Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Summary
rawMessagefield toSanitizedErrorso the chat UI displays the original provider error beneath the translated i18n hint, giving users more debugging contextoneOf/anyOftool input schemas into a single object schema, working around OpenAI's strict schema validation (OpenAI-compatible providers fail with tools - missing 'type: object' in JSON Schema vercel/ai#7924)Closes #1253
Closes #1254
Test plan
z.discriminatedUnion()schemas work correctly with OpenAI models (ChatGPT 5.2, 5.2 Pro, GPT-5.2 Instant)sanitize-chat-errorunit testsSummary by CodeRabbit