🧵 fix: Remove Empty String values from Gemini API Payload (#11213)

When users don't explicitly set `maxOutputTokens` in Google/Gemini endpoint
settings, LibreChat was sending `"maxOutputTokens": ""` instead of omitting
the field. This caused issues with Gemini SDK and AI reverse proxies that
expect numeric types.

Changes:
- Add `removeEmptyStrings=true` to `removeNullishValues()` in googleSchema
- Add `removeEmptyStrings=true` to `removeNullishValues()` in compactGoogleSchema
- Add `removeEmptyStrings=true` to `removeNullishValues()` in getGoogleConfig()
- Create comprehensive test suite for Google endpoint (45 tests)

The fix ensures empty strings for numeric fields like maxOutputTokens,
temperature, topP, and topK are properly removed from the request payload.

Closes #11187
This commit is contained in:
Danny Avila 2026-01-05 14:08:55 -05:00 committed by GitHub
parent 1544491737
commit e343180740
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 793 additions and 11 deletions

View file

@ -903,7 +903,7 @@ export const googleBaseSchema = tConversationSchema.pick({
});
export const googleSchema = googleBaseSchema
.transform((obj: Partial<TConversation>) => removeNullishValues(obj))
.transform((obj: Partial<TConversation>) => removeNullishValues(obj, true))
.catch(() => ({}));
/**
@ -1101,7 +1101,7 @@ export const compactGoogleSchema = googleBaseSchema
delete newObj.topK;
}
return removeNullishValues(newObj);
return removeNullishValues(newObj, true);
})
.catch(() => ({}));