fix: handle nested array items for Gemini schema validation (#11952)

This commit is contained in:
Muhammad Mugni Hadi
2026-02-03 22:24:52 +07:00
committed by GitHub
parent 76381f33d5
commit 3741516fe3
2 changed files with 122 additions and 2 deletions

View File

@@ -768,8 +768,15 @@ export namespace ProviderTransform {
result.required = result.required.filter((field: any) => field in result.properties)
}
if (result.type === "array" && result.items == null) {
result.items = {}
if (result.type === "array") {
if (result.items == null) {
result.items = {}
}
// Ensure items has at least a type if it's an empty object
// This handles nested arrays like { type: "array", items: { type: "array", items: {} } }
if (typeof result.items === "object" && !Array.isArray(result.items) && !result.items.type) {
result.items.type = "string"
}
}
// Remove properties/required from non-object types (Gemini rejects these)