mirror of
https://github.com/jwadow/kiro-gateway.git
synced 2026-04-25 01:15:57 +03:00
[GH-ISSUE #31] BUG: Error 422 on Claude code, after an initial success message #22
Labels
No labels
bug
bug
enhancement
enhancement
fixed
fixed
invalid
needs-info
needs-testing
pull-request
question
upstream
wontfix
workaround
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/kiro-gateway-jwadow#22
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @cristianadrielbraun on GitHub (Jan 11, 2026).
Original GitHub issue: https://github.com/jwadow/kiro-gateway/issues/31
Kiro Gateway Version
Latest
6ce52d9commitWhat happened?
Hello guys!
Okay so I was trying the gateway with CC, and I'm able to reproduce this consistently:
I tried with the latest Claude Code version but also with a few versions older
for the settings.json of claude, I'm using the ANTHROPIC_AUTH_TOKEN variable with the key; the ANTHROPIC_BASE_URL for the host. I experimented with a few extras like CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC, which in the logs, made the first message to NOT show a "422", but starting with the second we're back at 422
PS: enabling "errors" in the devug mode didn't generate any file, I had to go all the way to "debug"
Happy to help with more testing
Debug Logs
app_logs.txt
request_body.json
kiro_request_body.json
@jwadow commented on GitHub (Jan 11, 2026):
Hello again @cristianadrielbraun, I've improved the logger; it now catches 422 errors correctly.
Run
git pull(update to latest), specifyDEBUG_MODE=errors, wait for an error, and send me a new set of logs.P.S. The logs you sent me are incorrect; they're actually successful requests, because that's the only thing it caught, haha
@cristianadrielbraun commented on GitHub (Jan 11, 2026):
Okay so for some reason it's still not generating logs in the debug folder.. but I can show you the errors I'm getting in the server output if that's helpful:
2026-01-11 03:07:17 | ERROR | kiro.exceptions:validation_exception_handler:88 - Validation error (422): [{'type': 'string_type', 'loc': ['body', 'messages', 1, 'content', 'str'], 'msg': 'Input should be a valid string', 'input': [{'type': 'thinking', 'thinking': '\nThe user is greeting me casually. I should respond in a friendly but concise manner, as per my instructions to keep responses short and avoid unnecessary emojis or excessive praise.\n', 'signature': 'sig_8d3c146929cf410e8f4a7f1204ae7814'}, {'type': 'text', 'text': 'Hello! How can I help you today?', 'cache_control': {'type': 'ephemeral'}}]}, {'type': 'literal_error', 'loc': ['body', 'messages', 1, 'content', 'list[union[TextContentBlock,ImageContentBlock,ToolUseContentBlock,ToolResultContentBlock]]', 0, 'TextContentBlock', 'type'], 'msg': "Input should be 'text'", 'input': 'thinking', 'ctx': {'expected': "'text'"}}, {'type': 'missing', 'loc': ['body', 'messages', 1, 'content', 'list[union[TextContentBlock,ImageContentBlock,ToolUseContentBlock,ToolResultContentBlock]]', 0, 'TextContentBlock', 'text'], 'msg': 'Field required', 'input': {'type': 'thinking', 'thinking': '\nThe user is greeting me casually. I should respond in a friendly but concise manner, as per my instructions to keep responses short and avoid unnecessary emojis or excessive praise.\n', 'signature': 'sig_8d3c146929cf410e8f4a7f1204ae7814'}}, {'type': 'literal_error', 'loc': ['body', 'messages', 1, 'content', 'list[union[TextContentBlock,ImageContentBlock,ToolUseContentBlock,ToolResultContentBlock]]', 0, 'ImageContentBlock', 'type'], 'msg': "Input should be 'image'", 'input': 'thinking', 'ctx': {'expected': "'image'"}}, {'type': 'missing', 'loc': ['body', 'messages', 1, 'content', 'list[union[TextContentBlock,ImageContentBlock,ToolUseContentBlock,ToolResultContentBlock]]', 0, 'ImageContentBlock', 'source'], 'msg': 'Field required', 'input': {'type': 'thinking', 'thinking': '\nThe user is greeting me casually. I should respond in a friendly but concise manner, as per my instructions to keep responses short and avoid unnecessary emojis or excessive praise.\n', 'signature': 'sig_8d3c146929cf410e8f4a7f1204ae7814'}}, {'type': 'literal_error', 'loc': ['body', 'messages', 1, 'content', 'list[union[TextContentBlock,ImageContentBlock,ToolUseContentBlock,ToolResultContentBlock]]', 0, 'ToolUseContentBlock', 'type'], 'msg': "Input should be 'tool_use'", 'input': 'thinking', 'ctx': {'expected': "'tool_use'"}}, {'type': 'missing', 'loc': ['body', 'messages', 1, 'content', 'list[union[TextContentBlock,ImageContentBlock,ToolUseContentBlock,ToolResultContentBlock]]', 0, 'ToolUseContentBlock', 'id'], 'msg': 'Field required', 'input': {'type': 'thinking', 'thinking': '\nThe user is greeting me casually. I should respond in a friendly but concise manner, as per my instructions to keep responses short and avoid unnecessary emojis or excessive praise.\n', 'signature': 'sig_8d3c146929cf410e8f4a7f1204ae7814'}}, {'type': 'missing', 'loc': ['body', 'messages', 1, 'content', 'list[union[TextContentBlock,ImageContentBlock,ToolUseContentBlock,ToolResultContentBlock]]', 0, 'ToolUseContentBlock', 'name'], 'msg': 'Field required', 'input': {'type': 'thinking', 'thinking': '\nThe user is greeting me casually. I should respond in a friendly but concise manner, as per my instructions to keep responses short and avoid unnecessary emojis or excessive praise.\n', 'signature': 'sig_8d3c146929cf410e8f4a7f1204ae7814'}}, {'type': 'missing', 'loc': ['body', 'messages', 1, 'content', 'list[union[TextContentBlock,ImageContentBlock,ToolUseContentBlock,ToolResultContentBlock]]', 0, 'ToolUseContentBlock', 'input'], 'msg': 'Field required', 'input': {'type': 'thinking', 'thinking': '\nThe user is greeting me casually. I should respond in a friendly but concise manner, as per my instructions to keep responses short and avoid unnecessary emojis or excessive praise.\n', 'signature': 'sig_8d3c146929cf410e8f4a7f1204ae7814'}}, {'type': 'literal_error', 'loc': ['body', 'messages', 1, 'content', 'list[union[TextContentBlock,ImageContentBlock,ToolUseContentBlock,ToolResultContentBlock]]', 0, 'ToolResultContentBlock', 'type'], 'msg': "Input should be 'tool_result'", 'input': 'thinking', 'ctx': {'expected': "'tool_result'"}}, {'type': 'missing', 'loc': ['body', 'messages', 1, 'content', 'list[union[TextContentBlock,ImageContentBlock,ToolUseContentBlock,ToolResultContentBlock]]', 0, 'ToolResultContentBlock', 'tool_use_id'], 'msg': 'Field required', 'input': {'type': 'thinking', 'thinking': '\nThe user is greeting me casually. I should respond in a friendly but concise manner, as per my instructions to keep responses short and avoid unnecessary emojis or excessive praise.\n', 'signature': 'sig_8d3c146929cf410e8f4a7f1204ae7814'}}] 2026-01-11 03:07:17 | INFO | kiro.debug_logger:flush_on_error:310 - [DebugLogger] Error logs flushed to debug_logs (status=422) 2026-01-11 03:07:17 | INFO | logging:callHandlers:1737 - 127.0.0.1:45330 - "POST /v1/messages?beta=true HTTP/1.1" 422 2026-01-11 03:07:17 | ERROR | kiro.exceptions:validation_exception_handler:88 - Validation error (422): [{'type': 'string_type', 'loc': ['body', 'messages', 1, 'content', 'str'], 'msg': 'Input should be a valid string', 'input': [{'type': 'thinking', 'thinking': '\nThe user is greeting me casually. I should respond in a friendly but concise manner, as per my instructions to keep responses short and avoid unnecessary emojis or excessive praise.\n', 'signature': 'sig_8d3c146929cf410e8f4a7f1204ae7814'}, {'type': 'text', 'text': 'Hello! How can I help you today?', 'cache_control': {'type': 'ephemeral'}}]}, {'type': 'literal_error', 'loc': ['body', 'messages', 1, 'content', 'list[union[TextContentBlock,ImageContentBlock,ToolUseContentBlock,ToolResultContentBlock]]', 0, 'TextContentBlock', 'type'], 'msg': "Input should be 'text'", 'input': 'thinking', 'ctx': {'expected': "'text'"}}, {'type': 'missing', 'loc': ['body', 'messages', 1, 'content', 'list[union[TextContentBlock,ImageContentBlock,ToolUseContentBlock,ToolResultContentBlock]]', 0, 'TextContentBlock', 'text'], 'msg': 'Field required', 'input': {'type': 'thinking', 'thinking': '\nThe user is greeting me casually. I should respond in a friendly but concise manner, as per my instructions to keep responses short and avoid unnecessary emojis or excessive praise.\n', 'signature': 'sig_8d3c146929cf410e8f4a7f1204ae7814'}}, {'type': 'literal_error', 'loc': ['body', 'messages', 1, 'content', 'list[union[TextContentBlock,ImageContentBlock,ToolUseContentBlock,ToolResultContentBlock]]', 0, 'ImageContentBlock', 'type'], 'msg': "Input should be 'image'", 'input': 'thinking', 'ctx': {'expected': "'image'"}}, {'type': 'missing', 'loc': ['body', 'messages', 1, 'content', 'list[union[TextContentBlock,ImageContentBlock,ToolUseContentBlock,ToolResultContentBlock]]', 0, 'ImageContentBlock', 'source'], 'msg': 'Field required', 'input': {'type': 'thinking', 'thinking': '\nThe user is greeting me casually. I should respond in a friendly but concise manner, as per my instructions to keep responses short and avoid unnecessary emojis or excessive praise.\n', 'signature': 'sig_8d3c146929cf410e8f4a7f1204ae7814'}}, {'type': 'literal_error', 'loc': ['body', 'messages', 1, 'content', 'list[union[TextContentBlock,ImageContentBlock,ToolUseContentBlock,ToolResultContentBlock]]', 0, 'ToolUseContentBlock', 'type'], 'msg': "Input should be 'tool_use'", 'input': 'thinking', 'ctx': {'expected': "'tool_use'"}}, {'type': 'missing', 'loc': ['body', 'messages', 1, 'content', 'list[union[TextContentBlock,ImageContentBlock,ToolUseContentBlock,ToolResultContentBlock]]', 0, 'ToolUseContentBlock', 'id'], 'msg': 'Field required', 'input': {'type': 'thinking', 'thinking': '\nThe user is greeting me casually. I should respond in a friendly but concise manner, as per my instructions to keep responses short and avoid unnecessary emojis or excessive praise.\n', 'signature': 'sig_8d3c146929cf410e8f4a7f1204ae7814'}}, {'type': 'missing', 'loc': ['body', 'messages', 1, 'content', 'list[union[TextContentBlock,ImageContentBlock,ToolUseContentBlock,ToolResultContentBlock]]', 0, 'ToolUseContentBlock', 'name'], 'msg': 'Field required', 'input': {'type': 'thinking', 'thinking': '\nThe user is greeting me casually. I should respond in a friendly but concise manner, as per my instructions to keep responses short and avoid unnecessary emojis or excessive praise.\n', 'signature': 'sig_8d3c146929cf410e8f4a7f1204ae7814'}}, {'type': 'missing', 'loc': ['body', 'messages', 1, 'content', 'list[union[TextContentBlock,ImageContentBlock,ToolUseContentBlock,ToolResultContentBlock]]', 0, 'ToolUseContentBlock', 'input'], 'msg': 'Field required', 'input': {'type': 'thinking', 'thinking': '\nThe user is greeting me casually. I should respond in a friendly but concise manner, as per my instructions to keep responses short and avoid unnecessary emojis or excessive praise.\n', 'signature': 'sig_8d3c146929cf410e8f4a7f1204ae7814'}}, {'type': 'literal_error', 'loc': ['body', 'messages', 1, 'content', 'list[union[TextContentBlock,ImageContentBlock,ToolUseContentBlock,ToolResultContentBlock]]', 0, 'ToolResultContentBlock', 'type'], 'msg': "Input should be 'tool_result'", 'input': 'thinking', 'ctx': {'expected': "'tool_result'"}}, {'type': 'missing', 'loc': ['body', 'messages', 1, 'content', 'list[union[TextContentBlock,ImageContentBlock,ToolUseContentBlock,ToolResultContentBlock]]', 0, 'ToolResultContentBlock', 'tool_use_id'], 'msg': 'Field required', 'input': {'type': 'thinking', 'thinking': '\nThe user is greeting me casually. I should respond in a friendly but concise manner, as per my instructions to keep responses short and avoid unnecessary emojis or excessive praise.\n', 'signature': 'sig_8d3c146929cf410e8f4a7f1204ae7814'}}]On claude code itself, this is what I see:
is this helpful or do you require the debug files?
@jwadow commented on GitHub (Jan 11, 2026):
@cristianadrielbraun, fixed it!
Turns out I missed one line. When Claude Code sends back the conversation history, it includes
thinkingblocks from previous responses. Our Pydantic models didnt know about that type so it was rejecting them with 422.Just added
ThinkingContentBlockto the union and now it works.Do a
git pulland try again, should be good now.About the debug logs not showing up in the folder, thats weird because your console shows the flush happening:
[DebugLogger] Error logs flushed to debug_logs (status=422)Maybe check if the
debug_logsfolder exists and has write permissions? Or if youre running the server from the project root? Let me know if it still doesnt work after the update.@cristianadrielbraun commented on GitHub (Jan 11, 2026):
I know this is closed already but I just wanted to thank you, looks like it's working now. amazing!