[GH-ISSUE #30] BUG: 422 Validation Error: Unsupported 'image' content block in messages #19

Closed
opened 2026-02-27 07:17:28 +03:00 by kerem · 1 comment
Owner

Originally created by @smileheart0708 on GitHub (Jan 10, 2026).
Original GitHub issue: https://github.com/jwadow/kiro-gateway/issues/30

Kiro Gateway Version

v2.0-rc.1

What happened?

Summary:
The gateway returns a 422 Unprocessable Entity error when a request contains an image content block in the messages.

Steps to Reproduce:

Send a request to the /v1/messages endpoint.
Include an image in the message content (e.g., via copy-pasting an image in the chat or sending a base64 image block).
Actual Result:
The request fails with a validation error because the backend models do not recognize the image type. The error log shows that the validator expects a text block but receives an image block:

{ "type": "literal_error", "loc": ["body", "messages", 0, "content", 4, "TextContentBlock", "type"], "msg": "Input should be 'text'", "input": "image", "ctx": {"expected": "'text'"} } Expected Behavior: The gateway should support image content blocks as per the Anthropic Messages API specification, or at least handle them without a 422 validation crash.

Debug Logs

Summary:
The gateway returns a 422 Unprocessable Entity error when a request contains an image content block in the messages.

Steps to Reproduce:

Send a request to the /v1/messages endpoint.
Include an image in the message content (e.g., via copy-pasting an image in the chat or sending a base64 image block).
Actual Result:
The request fails with a validation error because the backend models do not recognize the image type. The error log shows that the validator expects a text block but receives an image block:

{ "type": "literal_error", "loc": ["body", "messages", 0, "content", 4, "TextContentBlock", "type"], "msg": "Input should be 'text'", "input": "image", "ctx": {"expected": "'text'"} } Expected Behavior: The gateway should support image content blocks as per the Anthropic Messages API specification, or at least handle them without a 422 validation crash.
Originally created by @smileheart0708 on GitHub (Jan 10, 2026). Original GitHub issue: https://github.com/jwadow/kiro-gateway/issues/30 ### Kiro Gateway Version v2.0-rc.1 ### What happened? Summary: The gateway returns a 422 Unprocessable Entity error when a request contains an image content block in the messages. Steps to Reproduce: Send a request to the /v1/messages endpoint. Include an image in the message content (e.g., via copy-pasting an image in the chat or sending a base64 image block). Actual Result: The request fails with a validation error because the backend models do not recognize the image type. The error log shows that the validator expects a text block but receives an image block: <JSON> { "type": "literal_error", "loc": ["body", "messages", 0, "content", 4, "TextContentBlock", "type"], "msg": "Input should be 'text'", "input": "image", "ctx": {"expected": "'text'"} } Expected Behavior: The gateway should support image content blocks as per the Anthropic Messages API specification, or at least handle them without a 422 validation crash. ### Debug Logs Summary: The gateway returns a 422 Unprocessable Entity error when a request contains an image content block in the messages. Steps to Reproduce: Send a request to the /v1/messages endpoint. Include an image in the message content (e.g., via copy-pasting an image in the chat or sending a base64 image block). Actual Result: The request fails with a validation error because the backend models do not recognize the image type. The error log shows that the validator expects a text block but receives an image block: <JSON> { "type": "literal_error", "loc": ["body", "messages", 0, "content", 4, "TextContentBlock", "type"], "msg": "Input should be 'text'", "input": "image", "ctx": {"expected": "'text'"} } Expected Behavior: The gateway should support image content blocks as per the Anthropic Messages API specification, or at least handle them without a 422 validation crash.
kerem 2026-02-27 07:17:28 +03:00
  • closed this issue
  • added the
    bug
    fixed
    labels
Author
Owner

@jwadow commented on GitHub (Jan 10, 2026):

Fixed! The 422 error was happening because the Pydantic models didn't have ImageContentBlock defined. Now images are properly validated and forwarded to Kiro API.

Shoutout to @cniu6 who submitted PR #26 yesterday with a similar fix - I had to close it due to some security concerns (verify=False in http client) but the image support architecture was solid and inspired this implementation. Added them to CONTRIBUTORS.md.

One thing to note though - while the gateway now correctly sends images to Kiro in the right format, the actual vision capability seems to depend on the Kiro backend. In my testing images go through without errors but the model doesn't seem to actually see them. That's on their end, not something we can fix here. Although everything is possible.

<!-- gh-comment-id:3732914028 --> @jwadow commented on GitHub (Jan 10, 2026): Fixed! The 422 error was happening because the Pydantic models didn't have ImageContentBlock defined. Now images are properly validated and forwarded to Kiro API. Shoutout to @cniu6 who submitted PR #26 yesterday with a similar fix - I had to close it due to some security concerns (verify=False in http client) but the image support architecture was solid and inspired this implementation. Added them to CONTRIBUTORS.md. One thing to note though - while the gateway now correctly sends images to Kiro in the right format, the actual vision capability seems to depend on the Kiro backend. In my testing images go through without errors but the model doesn't seem to actually see them. That's on their end, not something we can fix here. Although everything is possible.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/kiro-gateway-jwadow#19
No description provided.