Skip to content

ValidationException: text content blocks must be non-empty when using Bedrock Runtime #15715

@icodeu

Description

@icodeu

Description

Description

When using opencode with AWS Bedrock Runtime (InvokeModelWithResponseStream), a ValidationException is thrown with the message:

messages: text content blocks must be non-empty
This error occurs during normal conversation — no empty message was sent by the user. It appears opencode is generating a request that contains an empty text content block, which Bedrock rejects.

Error Message

InvokeModelWithResponseStream: operation error Bedrock Runtime: InvokeModelWithResponseStream,
https response error StatusCode: 400,
RequestID: 1864b9d1-6a4d-441b-a404-46e48820db57,
ValidationException: messages: text content blocks must be non-empty

Steps to Reproduce

  1. Start a normal conversation session using opencode with AWS Bedrock as the provider
  2. Send a non-empty message
  3. Error occurs consistently on every request

Expected Behavior

Messages are sent to Bedrock API with valid, non-empty text content blocks.

Actual Behavior

Bedrock returns HTTP 400 with ValidationException: messages: text content blocks must be non-empty, suggesting opencode is including an empty text block in the API request body.

Environment

  • Platform: macOS (darwin)
  • Provider: AWS Bedrock Runtime
  • Model: Claude Sonnet 4.6
  • Provider: Custom Provider

Possible Cause

opencode may be including empty text content blocks (e.g. {"type": "text", "text": ""}) in the messages array when constructing the API request, possibly related to tool use results or message history serialization.

Plugins

No response

OpenCode version

1.2.15

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions