fix(translator): handle non-string types in tools result processing

- Skip setting values for non-string `type` fields to prevent runtime errors.

Closes: #2226
This commit is contained in:
Luis Pater
2026-05-04 05:08:31 +08:00
parent 82ebe24b9e
commit a1487b0958
2 changed files with 83 additions and 1 deletions
@@ -284,7 +284,11 @@ func ConvertGeminiRequestToCodex(modelName string, inputRawJSON []byte, _ bool)
util.Walk(toolsResult, "", "type", &pathsToLower)
for _, p := range pathsToLower {
fullPath := fmt.Sprintf("tools.%s", p)
out, _ = sjson.SetBytes(out, fullPath, strings.ToLower(gjson.GetBytes(out, fullPath).String()))
typeValue := gjson.GetBytes(out, fullPath)
if typeValue.Type != gjson.String {
continue
}
out, _ = sjson.SetBytes(out, fullPath, strings.ToLower(typeValue.String()))
}
return out