Bug: boolean JSON Schema subschemas (e.g. "items": true) pass through claude→openai chat-completions translation and get 400 from strict upstreams (Volcengine Ark code 11133, codebuddyCN 400001)

Author: xyoniumCreated Sep 30, 2026Updated Sep 30, 2026

Follow-up to #3551, which fixed the gemini path (c93978c4) but left the claude → OpenAI chat-completions path still passing boolean subschemas through verbatim.

Symptoms

Claude Code (via /v1/messages) → openai-compatibility providers rejects valid requests with:

{"type":"error","error":{"type":"invalid_request_error","message":"[400]: {\"code\":11133,\"msg\":\"Invalid request parameters\",...,\"extError\":{\"code\":\"400001\",\"message\":\"the request parameters were rejected by the model provider\",...}"}}}

Observed on Volcengine Ark coding plan (ark.cn-beijing.volces.com/api/coding/v3) with kimi-k3 and on the 9router codebuddyCN gateway with the same model. Other models behind the same gateways (e.g. glm-5.3) accept the exact same request.

Root cause

MCP servers can emit valid JSON Schema boolean subschemas. The Rancher MCP server declares a tool parameter as:

json
"patch": {"type": "array", "items": true, "description": "RFC 6902 JSON patch array..."}

"items": true is legal JSON Schema ("array elements can be anything"), but strict upstream validators reject it.

normalizeObjectSchemaProperties in internal/translator/openai/claude/openai_claude_request.go recurses into map/array subschema values only, so true/false fall through untouched and reach the upstream. The gemini path got the equivalent normalization in c93978c4 (internal/util/gemini_schema.go); this path was missed.

Evidence (A/B replay)

One captured 59-tool / 35-message request body, replayed with curl:

Request Upstream Result
translated body as-is (contains items: true) Ark kimi-k3 ❌ 400 InvalidParameter
same bytes, model changed to glm-5.3 Ark ✅ 200
same body, items: true → items: {"type":"object"}, model kimi-k3 Ark kimi-k3 ✅ 200

Also verified reasoning_effort is not a factor (fails/passes identically with and without it).

Proposed fix (verified locally against the captured production request)

Normalize boolean subschemas to empty object schemas in normalizeObjectSchemaProperties — at the recursion entry and for util.SchemaValueKeywords values:

diff
diff --git a/internal/translator/openai/claude/openai_claude_request.go b/internal/translator/openai/claude/openai_claude_request.go
index 5515532a..b2c4d613 100644
--- a/internal/translator/openai/claude/openai_claude_request.go
+++ b/internal/translator/openai/claude/openai_claude_request.go
@@ -423,6 +423,13 @@ func convertClaudeRequestToOpenAI(modelName string, inputRawJSON []byte, stream
 
 func normalizeObjectSchemaProperties(schema any) any {
 	switch value := schema.(type) {
+	case bool:
+		// JSON Schema boolean subschemas (true/false) are valid but strict upstream
+		// validators (Volcengine Ark, some OpenAI-compatible gateways) reject them.
+		// Normalize `true` (accept anything) to an empty object schema; `false`
+		// accepts nothing and has no object equivalent, so drop to empty as well
+		// to keep the schema structurally valid.
+		return map[string]any{}
 	case map[string]any:
 		if schemaType, ok := value["type"].(string); ok && schemaType == "object" {
 			if _, ok := value["properties"]; !ok {
@@ -458,6 +465,10 @@ func normalizeObjectSchemaProperties(schema any) any {
 		for _, valKey := range util.SchemaValueKeywords {
 			if val, exists := value[valKey]; exists {
 				switch sub := val.(type) {
+				case bool:
+					// Boolean subschemas are valid JSON Schema but strict upstream
+					// validators reject them; normalize them like any other subschema.
+					value[valKey] = normalizeObjectSchemaProperties(sub)
 				case map[string]any:
 					value[valKey] = normalizeObjectSchemaProperties(sub)
 				case []any:

With a regression test following the style of TestConvertClaudeRequestToOpenAI_ToolSchemaAddsMissingObjectProperties:

go
func TestConvertClaudeRequestToOpenAI_NormalizesBooleanSubschemas(t *testing.T) {
	inputJSON := []byte(`{
		"model": "claude-3-opus",
		"tools": [
			{
				"name": "patch_tool",
				"description": "Applies a JSON patch",
				"input_schema": {
					"type": "object",
					"properties": {
						"patch": {"type": "array", "items": true},
						"anything": true,
						"either": {"anyOf": [true, {"type": "string"}]}
					}
				}
			}
		],
		"messages": [{"role": "user", "content": "hello"}]
	}`)

	output := ConvertClaudeRequestToOpenAI("test-model", inputJSON, false)
	outputJSON := gjson.ParseBytes(output)

	params := outputJSON.Get("tools.0.function.parameters")
	if !params.Exists() {
		t.Fatalf("parameters missing: %s", outputJSON.Raw)
	}
	if got := params.Get("properties.patch.items"); !got.Exists() || got.Type == gjson.True || got.Raw == "true" {
		t.Fatalf("array items boolean subschema not normalized: %s", params.Get("properties.patch").Raw)
	}
	if got := params.Get("properties.anything"); !got.IsObject() {
		t.Fatalf("boolean property subschema not normalized to object: %s", params.Get("properties.anything").Raw)
	}
	if got := params.Get("properties.either.anyOf.0"); !got.IsObject() {
		t.Fatalf("boolean anyOf branch not normalized to object: %s", params.Get("properties.either").Raw)
	}
}

Semantics are unchanged (true and {} accept the same set of values), so lenient upstreams are unaffected.

Filing as an issue per the contributor policy for internal/translator/ changes. Happy to adjust the approach if maintainers prefer handling it in a shared helper next to internal/util/claude_schema.go (other directions, e.g. codex→claude, may have the same gap).

Source: router-for-me/CLIProxyAPI