-
Notifications
You must be signed in to change notification settings - Fork 620
Description
Bug Report: google-genai Plugin Deletes "Falsy" Parameter Values (False / 0)
Package: @genkit-ai/google-genai
Version: 1.27.0 (and earlier)
Source File: js/plugins/google-genai/src/vertexai/converters.ts
Compiled File: lib/vertexai/converters.js
Function: toImagenParameters
Issue Description
The toImagenParameters function in the google-genai plugin sanitizes the config object by deleting any keys with "falsy" values. This is incorrect behavior for boolean flags (where false is a meaningful value) and numeric parameters (where 0 might be valid).
Specifically for Imagen, the addWatermark parameter defaults to true on the Vertex AI API side. To disable it, the client must send addWatermark: false.
However, because false is falsy in JavaScript, the current plugin logic deletes this parameter entirely. The API then receives a request without addWatermark, triggering the default true, making it impossible to disable watermarks (and consequently making it impossible to use seed, which conflicts with watermarks).
Code location
File: src/vertexai/converters.ts (approx line 97)
function toImagenParameters(request: any) {
const params = {
sampleCount: request.candidates ?? 1,
...request?.config,
};
for (const k in params) {
// BUG: This deletes false, 0, undefined, null, ""
if (!params[k]) delete params[k];
}
return params;
}Recommended Fix
Update the filter condition to only remove keys that are strictly undefined or null.
function toImagenParameters(request: any) {
const params = {
sampleCount: request.candidates ?? 1,
...request?.config,
};
for (const k in params) {
// FIX: Only delete if undefined or null
if (params[k] === undefined || params[k] === null) delete params[k];
}
return params;
}Impact
- Watermarks: Users cannot disable watermarks (
addWatermark: falseis stripped). - Deterministic Generation: Users cannot use
seedbecause it requires watermarks to be disabled. - Zero Values: Any future parameter expecting a
0index or value will differ from intent.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status