Skip to content

Array of SystemContentBloc must not be sent if text is empty #167

@vrcdx64

Description

@vrcdx64

Describe the bug
When the gateway build the payload to send to Bedrock, it can integrate a "system" array in the JSON payload which is an array of SystemContentBlock objects.

If the raw request payload sent to bedrock-access-gateway has a message object like this:

{
  "messages": [
    {
      "name": null,
      "role": "system",
      "content": ""
    },
   ... Other messages blocs...
  ]

The Bedrock request must not include it because it's length is < 1 which cause an HTTP 500 error: Invalid length for parameter system[0].text, value: 0, valid min length: 1.

Bedrock request:

{
  "modelId": "us.anthropic.claude-3-7-sonnet-20250219-v1:0",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "text": "user message.."
        }
      ]
    },
    {
      "role": "assistant",
      "content": [
        {
          "text": "assistant message..."
        }
      ]
    },
    {
      "role": "user",
      "content": [
        {
          "text": "user message..."
        }
      ]
    }
  ],
  "system": [
    {
      "text": ""
    }
  ],
  "inferenceConfig": {
    "temperature": 1.0,
    "maxTokens": 5000,
    "topP": 1.0
  }
}

Please complete the following information:

  • Which API you used: /api/v1/chat/completions
  • Which model you used: us.anthropic.claude-3-7-sonnet-20250219-v1:0

To Reproduce
Send a RAW payload to bedrock-access-gateway with system content set to an empty string.

Expected behavior
Bedrock request sent without the empty string to prevent HTTP 500 error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions