FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(provider): filter empty text content blocks for Bedrock by zerone0x · Pull Request #15777 · anomalyco/opencode · GitHub

fix(provider): filter empty text content blocks for Bedrock - #15777

Closed
zerone0x wants to merge 1 commit into
anomalyco:devfrom
zerone0x:fix/issue-15715-bedrock-empty-text-blocks
Closed

fix(provider): filter empty text content blocks for Bedrock#15777
zerone0x wants to merge 1 commit into
anomalyco:devfrom
zerone0x:fix/issue-15715-bedrock-empty-text-blocks

Conversation

zerone0x commented Mar 3, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

Summary

Fixes #15715
Fixes #13811

Problem

AWS Bedrock rejects API requests that contain empty text content blocks with:

ValidationException: messages: text content blocks must be non-empty

Root Cause

normalizeMessages() in transform.ts already filters out empty text/reasoning content blocks — but the guard only applied to @ai-sdk/anthropic. AWS Bedrock (@ai-sdk/amazon-bedrock) has the same constraint on the API level, so it was silently passing empty blocks through.

Fix

Extend the existing empty-content filter to cover @ai-sdk/amazon-bedrock as well:

- // Anthropic rejects messages with empty content - filter out empty string messages
+ // Anthropic and Bedrock reject messages with empty content - filter out empty string messages
  // and remove empty text/reasoning parts from array content
- if (model.api.npm === "@ai-sdk/anthropic") {
+ if (model.api.npm === "@ai-sdk/anthropic" || model.api.npm === "@ai-sdk/amazon-bedrock") {

Tests

Added a new describe block mirroring the Anthropic empty-content filtering tests for Bedrock, covering:

  • Empty string content messages
  • Empty text parts in array content
  • All-empty messages being removed entirely
  • Non-text/reasoning parts preserved even when text parts are empty

AWS Bedrock rejects messages containing empty text content blocks with
'ValidationException: messages: text content blocks must be non-empty'.

The empty-content filter in normalizeMessages() was only applied to
the @ai-sdk/anthropic provider. Extend it to also cover
@ai-sdk/amazon-bedrock which has the same API constraint.

Fixes anomalyco#15715
github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Mar 3, 2026

github-actions Bot commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

github-actions Bot commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

I found a potentially related PR:

Related PR:

This appears to be addressing the exact same issue as the current PR #15777. Both are about filtering empty content blocks for the Bedrock provider. You should verify whether #14586 was already merged or closed, and if so, whether the current PR (#15777) is based on or supersedes it.

github-actions Bot commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant


Back | FazBrowse Home | New Git URL