[BUG] Randomly Hitting “Malformed input request” (HTTP 400) Error on AWS Bedrock with Claude CLI ≥ 0.2.107
Status Closed — not planned
Maintainer reply ✓ Yes — ant-kurt
Workaround ✓ Mentioned in thread ↓
Activity 15 comments · opened May 15, 2025 · closed Dec 9, 2025
💡 Likely answer: A maintainer (ant-kurt, collaborator)
responded on this thread — see the highlighted reply below.
Environment
- Platform (select one):
- [ ] Anthropic API
- [X] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other
- Claude CLI version:
0.2.115 - Operating System:
macOS 15.3.2 (24D81) - Terminal:
Warp
Bug Description
Every Claude CLI release after 0.2.106 randomly fails on AWS Bedrock with API Error: 400 Malformed input request, please reformat your input and try again..
Only downgrading to 0.2.106 or below restores the functionality.
Steps to Reproduce
npm i -g @anthropic-ai/claude-code@0.2.115(or any version ≥0.2.107).- Ensure Bedrock is being used, e.g.
export CLAUDE_CODE_USE_BEDROCK=1. - Start an interactive shell:
claude. - Send a request (or a couple) to claude.
- Sometimes, the
400error appears on the very first request. Other times, it may be after 2-3 requests 🤷♂. - Downgrade:
npm i -g @anthropic-ai/claude-code@0.2.106→ issue disappears.
Expected Behavior
The CLI should work as expected with AWS Bedrock.
Actual Behavior
Requests fail with the above error.
15 Comments
Hi @indrasvat - I'm not able to reproduce this on my end. If you run with
DEBUG=true, you can see the requests going out. Can you confirm that the payloads look as you expect, and share the failing request paths?Looks like versions after
0.2.106are sometimes injecting athinking: undefinedin thePOSTrequest payload, which is perhaps making Bedrock grumpy 🤷🏼?claude==0.2.115(_fails_)claude==0.2.106(_works_)Actually, the
thinking: undefinedis prolly not the issue. I editedlib/node_modules/@anthropic-ai/claude-code/cli.jsin my local install and removed that block (also added a log message to ensure it was picking my changes). The below interaction is interesting since the first request succeeds but then the following one fails with the400error. Nothinkingblock in any request.Not sure if this helps clarify things more.
Ok, it seems the
toolsarray length is causing the issue. A length> 128seems to cause it to fail with that400error. Tested with0.2.120.tools.length==130tools.length==128The below
jscodeshiftscript applies this _fix_ to the localcli.jsand things start working again.Running the script:
The updated
cli.jssection:I have several local MCPs configured:
Hope this helps!
@wolffiex @ant-kurt, please advice. Is there a better way to address this? This
toolsarray size restriction seems to be some limit Bedrock is enforcing 🤷♂.Thanks for the thorough investigation on this @indrasvat - I'm circling back with the team and will provide an update.
@indrasvat - unfortunately we don't have a workaround for this right now, other than passing in fewer tools. Appreciate your investigation on this!
Latest jscodeshift script for claude code
1.x:indrasvat/add-bedrock-tools-check-to-minified-claude-code-cli.js.I can confirm I'm experiencing this issue as well.
A few questions that would help with debugging:
Having visibility into the actual requests would help confirm I'm hitting the same error and provide the technical details needed for any AWS escalation.
ANTHROPIC_LOG=debugis the replacement forDEBUG=true.If your tool count is 17, I wouldn't expect the default tools in Claude Code to be pushing you over 128 total tools. Once you get the debug logs via the above, can you check the limit in the error message?
I opened a AWS support ticket - 175232731800026 and I would encourage others to do the same
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
I always got this error when running the
/contextcommand inv2.0.x. Only the remote AWS documentation mcp is installed.⎿ Error: 400 Malformed input request: #: subject must not be valid against schema {"required":["messages"]}#/tools/0: required key [type] not found#/tools/0: extraneous key [input_schema]
is not permitted#/tools/0: extraneous key [description] is not permitted#/tools/0/name: #/tools/0/name: mcp__plugin_aws-cdk_aws-documentation-mcp-server__aws___recommend is not a valid
enum value#/tools/0: required key [type] not found#/tools/0: required key [display_height_px] not found#/tools/0: required key [display_width_px] not found#/tools/0: extraneous key
[input_schema] is not permitted#/tools/0: extraneous key [description] is not permitted#/tools/0/name: #/tools/0/name: mcp__plugin_aws-cdk_aws-documentation-mcp-server__aws___recommend is
not a valid enum value#/tools/0: required key [type] not found#/tools/0: extraneous key [input_schema] is not permitted#/tools/0: extraneous key [description] is not
permitted#/tools/0/name: mcp__plugin_aws-cdk_aws-documentation-mcp-server__aws___recommend is not a valid enum value#/tools/0/name: #/tools/0/name: expected maxLength: 64, actual:
65#/tools/0/name: string [mcp__plugin_aws-cdk_aws-documentation-mcp-server__aws___recommend] does not match pattern ^[a-zA-Z0-9_-]{1,64}$, please reformat your input and try again.
BTW:
ANTHROPIC_LOG=debugdoes not work for v2.This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.