Skip to content

[Bug]: 422 Unprocessable Entity when message content is sent as array (multi-part) instead of string #191

@jeffbski

Description

@jeffbski

🐛 Bug Description

Context: Zed editor using the openai_compatible provider pointed at Shimmy. When attaching a file via @filename in the Agent Panel, Zed sends the OpenAI multi-part content array format (per the OpenAI Chat Completions spec). Shimmy rejects this with a 422.

Error message received:

HTTP response error from Shimmy's API: status 422 Unprocessable Entity - 
"Failed to deserialize the JSON body into the target type: 
messages[1].content: invalid type: sequence, expected a string at line 1 column 7254"

Root cause: Shimmy's message deserializer only accepts content as a String, but the OpenAI spec allows content to be either a String or an array of content parts (text, image_url, etc.). This is the standard format used by Zed, Cursor, Continue, and other clients when attaching file context.

Request: Support the OpenAI-spec union type for content:
content: string | array<{ type: "text"|"image_url", text: string, ... }>

🔄 Steps to Reproduce

curl -s http://127.0.0.1:11435/v1/chat/completions   -H 'Content-Type: application/json'   -d '{
    "model": "qwen-qwen3-14b-q4-k-m",
    "messages": [
      {
        "role": "system",
        "content": "You are a helpful assistant."
      },
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "How do I specify the terraform version in this file?"
          },
          {
            "type": "text",
            "text": "```hcl\n# Contents of main.tf\nterraform {\n  required_providers {\n    aws = {\n      source = \"hashicorp/aws\"\n    }\n  }\n}\n```"
          }
        ]
      }
    ],
    "max_tokens": 512,
    "stream": false
  }'

Error: Failed to deserialize the JSON body into the target type: messages[1].content: invalid type: sequence, expected a string at line 10 column 19

Alternatively if using Zed, just try to attach a file using the "@file" along with the command.

✅ Expected Behavior

When attaching content using "@file", it should be able to utilize that content for execution of the command.

❌ Actual Behavior

In Zed, HTTP response error from Shimmy's API: status 422 Unprocessable Entity -
"Failed to deserialize the JSON body into the target type:
messages[1].content: invalid type: sequence, expected a string at line 1 column 7254"

From the curl command:
Failed to deserialize the JSON body into the target type: messages[1].content: invalid type: sequence, expected a string at line 10 column 19

📦 Shimmy Version

Latest (main branch)

💻 Operating System

macOS

📥 Installation Method

Pre-built binary from releases

🌍 Environment Details

  • Model: qwen-qwen3-14b-q4-k-m

📋 Logs/Error Messages

From Zed, status 422 Unprocessable Entity - 
"Failed to deserialize the JSON body into the target type: 
messages[1].content: invalid type: sequence, expected a string at line 1 column 7254"

From the curl command:
Failed to deserialize the JSON body into the target type: messages[1].content: invalid type: sequence, expected a string at line 10 column 19

📝 Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions