Skip to content

fix(provider): normalize openai-compatible schema required field#15538

Open
ca0fgh wants to merge 2 commits intoanomalyco:devfrom
ca0fgh:fix/deepseek-required-null-compatible
Open

fix(provider): normalize openai-compatible schema required field#15538
ca0fgh wants to merge 2 commits intoanomalyco:devfrom
ca0fgh:fix/deepseek-required-null-compatible

Conversation

@ca0fgh
Copy link

@ca0fgh ca0fgh commented Mar 1, 2026

Issue for this PR

Closes #15540

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Some OpenAI-compatible providers (for example DeepSeek via compatible gateways) can reject payloads when any object schema has required: null.

This PR normalizes outgoing POST schema payloads for @ai-sdk/openai, @ai-sdk/openai-compatible, and @ai-sdk/azure: when schema type is object and required is not an array, it sets required to [].

It keeps existing OpenAI item-id stripping behavior intact.

How did you verify your code works?

  • Added regression tests in test/provider/openai-schema-normalization.test.ts.
  • Ran:
    • bun test --timeout 30000 test/provider/openai-schema-normalization.test.ts
    • bun test --timeout 30000 test/provider/provider.test.ts test/provider/openai-schema-normalization.test.ts
  • Reproduced the real DeepSeek failure before fix and verified it no longer returns at '/required': got null, want array after this patch.

Screenshots / recordings

N/A (non-UI change)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Mar 1, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2026

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions bot removed needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Mar 1, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

OpenAI-compatible providers fail when object schema has required:null

1 participant