[BUG] Claude Code sends invalid tool schemas with `required: null`
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Claude Code sends invalid tool schemas with required: null
Summary
Claude Code CLI sends tool schemas where the required field is null instead of an empty array [] when tools have no required fields. This violates JSON Schema specification and causes strict validators (like AI Proxies and OpenAI-compatible endpoints) to reject requests with 400 Bad Request.
Error Message
API Error: 400 tools.67.custom.input_schema.required: Input should be a valid list
Expected Behavior
when a tool has no required fields, Claude Code should send:
{
"tools": [
{
"name": "example",
"custom": {
"input_schema": {
"type": "object",
"properties": {...},
"required": [] // Empty array, not null
}
}
}
]
}
Actual Behavior
Claude Code sends:
{
"tools": [
{
"name": "example",
"custom": {
"input_schema": {
"type": "object",
"properties": {...},
"required": null // Invalid - should be []
}
}
}
]
}
Or omits the field entirely:
{
"tools": [
{
"name": "example",
"custom": {
"input_schema": {
"type": "object",
"properties": {...}
// "required" field missing entirely
}
}
}
]
}
Impact
- Breaks proxying through strict JSON Schema validators
- Incompatible with AI Gateway's
- Incompatible with OpenAI-compatible API endpoints
- The Anthropic API itself is lenient and accepts this, but downstream systems don't
Environment
- Claude CLI: 2.1.112
- Runtime: Bun 1.3.13
- Proxy: Kong AI Gateway 3.14.0
Related
Similar issue with tool schema validation affects any strict JSON Schema compliant system downstream of Claude Code CLI.
What Should Happen?
Expected Behavior
when a tool has no required fields, Claude Code should send:
{
"tools": [
{
"name": "example",
"custom": {
"input_schema": {
"type": "object",
"properties": {...},
"required": [] // Empty array, not null
}
}
}
]
}
Actual Behavior
Claude Code sends:
{
"tools": [
{
"name": "example",
"custom": {
"input_schema": {
"type": "object",
"properties": {...},
"required": null // Invalid - should be []
}
}
}
]
}
Or omits the field entirely:
{
"tools": [
{
"name": "example",
"custom": {
"input_schema": {
"type": "object",
"properties": {...}
// "required" field missing entirely
}
}
}
]
}
Error Messages/Logs
## Error Message
API Error: 400 tools.67.custom.input_schema.required: Input should be a valid list
Steps to Reproduce
Steps to Reproduce
- Configure Claude Code CLI to proxy through an AI Gateway (or any JSON Schema validator)
- Run a command with Claude Code that uses tools
- Claude Code sends a POST request with
tools[N].custom.input_schema.required: null - The proxy/validator rejects the request
Claude Model
Other
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.112
Platform
AWS Bedrock
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗