Skip to content

BUG: Claude Code 2.1.168 sends system role causing 422 validation error #226

Description

@HARSHP55555

Kiro Gateway Version

v2.4.dev.13

What happened?

Environment
Kiro Gateway: v2.4.dev.13
Claude Code: 2.1.168
OS: Windows 11
Problem

After upgrading Claude Code, all requests fail with a 422 validation error.

Kiro Gateway starts successfully and authenticates correctly, but requests to /v1/messages?beta=true are rejected.

Error:

Validation error (422):
Input should be 'user' or 'assistant'
input: 'system'

Server log:

POST /v1/messages?beta=true HTTP/1.1" 422

Validation error (422):
[
{
"type": "literal_error",
"loc": ["body", "messages", 1, "role"],
"msg": "Input should be 'user' or 'assistant'",
"input": "system"
}
]
Investigation

The request payload contains a message with:

{
"role": "system",
"content": "..."
}

However the gateway model currently validates:

class AnthropicMessage(BaseModel):
role: Literal["user", "assistant"]

which causes validation to fail before the request is processed.

Suggested Fix

Allow system role messages, e.g.:

role: Literal["user", "assistant", "system"]

or consider using:

role: str

if newer Claude Code versions may introduce additional roles.

Reproduction
Start Kiro Gateway v2.4.dev.13
Configure Claude Code to use the gateway
Run claude
Enter a simple prompt such as hi
Observe 422 validation error

Debug Logs

● API Error: 422 {"detail":[{"type":"literal_error","loc":["body","messages",1,"role"],"msg":"Input should be 'user' or 'assistant'","input":"system","ctx":{"expected":"'user' or 'assistant'"}}],"body":"{"model":"claude-opus-4-8","messages":[{"role":"user","content":[{"type":"text","text":"\nAs you answer the user's questions, you can use the following context:\n# currentDate\nToday's date is 2026-06-18.\n\n IMPORTANT: this context may or may not be relevant to your tasks. You should not respond to this context unless it is highly relevant to your task.\n\n\n"},{"type":"text","text":"hi","cache_control":{"type":"ephemeral"}}]},{"role":"system","content":""}

2026-06-18 20:54:37 | ERROR | kiro.exceptions:validation_exception_handler:88 - Validation error (422): [{'type': 'literal_error', 'loc': ['body', 'messages', 1, 'role'], 'msg': "Input should be 'user' or 'assistant'", 'input': 'system', 'ctx': {'expected': "'user' or 'assistant'"}}]

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