{"record":{"id":"216642a53c0dc01c","repo":"HeyPuter/puter","slug":"field-invalid-216642","errorCode":"field_invalid","errorMessage":"Invalid model: ${model}. Expected: ${GEMINI_TTS_MODELS.map(({ id }) => id).join(', ')}","messagePattern":"Invalid model: (.+?)\\. Expected: (.+?)\\) => id\\)\\.join\\(', '\\)\\}","errorType":"validation","errorClass":"HttpError","httpStatus":400,"severity":"error","filePath":"src/backend/drivers/ai-tts/providers/gemini/GeminiTTSProvider.ts","lineNumber":154,"sourceCode":"            model: modelArg,\n            instructions,\n            test_mode,\n        } = args;\n\n        if (test_mode) {\n            return { url: SAMPLE_AUDIO_URL, content_type: 'audio' };\n        }\n\n        if (typeof text !== 'string' || !text.trim()) {\n            throw new HttpError(400, 'Missing required field: text', {\n                legacyCode: 'field_required',\n                fields: { key: 'text' },\n            });\n        }\n\n        const model = modelArg || DEFAULT_MODEL;\n        if (!GEMINI_TTS_MODELS.find(({ id }) => id === model)) {\n            throw new HttpError(\n                400,\n                `Invalid model: ${model}. Expected: ${GEMINI_TTS_MODELS.map(({ id }) => id).join(', ')}`,\n                {\n                    legacyCode: 'field_invalid',\n                    fields: {\n                        key: 'model',\n                        expected: GEMINI_TTS_MODELS.map(({ id }) => id).join(\n                            ', ',\n                        ),\n                        got: model,\n                    },\n                },\n            );\n        }\n\n        const voice = voiceArg || DEFAULT_VOICE;\n        if (\n            !GEMINI_TTS_VOICES.find(","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/HeyPuter/puter/blob/908ec23eda38526170322c3edf71ba45ecb1ca95/src/backend/drivers/ai-tts/providers/gemini/GeminiTTSProvider.ts#L136-L172","documentation":"GeminiTTSProvider.synthesize resolves model (defaulting to gemini-2.5-flash-preview-tts) and checks it against GEMINI_TTS_MODELS. If the id is not found, it throws HTTP 400 (legacyCode field_invalid) with fields.key='model', fields.expected (the supported ids), and fields.got.","triggerScenarios":"Passing model: 'gemini-1.5-flash' (a non-TTS Gemini model) or any id absent from GEMINI_TTS_MODELS. Only the specific '-tts' preview models are accepted.","commonSituations":"Using a chat/completion Gemini model id for TTS; passing a deprecated TTS model after Google renames it; typo; assuming any Gemini model can emit audio.","solutions":["Use a GEMINI_TTS_MODELS id: gemini-2.5-flash-preview-tts, gemini-2.5-pro-preview-tts, gemini-3.1-flash-tts-preview (read fields.expected).","Omit model to accept the default (gemini-2.5-flash-preview-tts).","Call list_engines({ provider: 'gemini' }) to fetch supported ids."],"exampleFix":"// before\nawait driver.synthesize({ text: 'hi', provider: 'gemini', model: 'gemini-1.5-flash' });\n// after\nawait driver.synthesize({ text: 'hi', provider: 'gemini', model: 'gemini-2.5-flash-preview-tts' });","handlingStrategy":"validation","validationCode":"const GEMINI_TTS_MODELS = ['gemini-2.5-flash-preview-tts', 'gemini-2.5-pro-preview-tts', 'gemini-3.1-flash-tts-preview'];\nfunction synthesizeGemini(text, model = 'gemini-2.5-flash-preview-tts') {\n  if (!GEMINI_TTS_MODELS.includes(model)) {\n    throw new Error(`Unsupported Gemini TTS model: ${model}. Use one of: ${GEMINI_TTS_MODELS.join(', ')}`);\n  }\n  return driver.synthesize({ text, provider: 'gemini', model });\n}","typeGuard":"const GEMINI_TTS_MODELS = ['gemini-2.5-flash-preview-tts', 'gemini-2.5-pro-preview-tts', 'gemini-3.1-flash-tts-preview'] as const;\ntype GeminiTTSModel = typeof GEMINI_TTS_MODELS[number];\n\nconst isGeminiTTSModel = (v: unknown): v is GeminiTTSModel =>\n  typeof v === 'string' && (GEMINI_TTS_MODELS as readonly string[]).includes(v);","tryCatchPattern":null,"preventionTips":["Only '-tts' preview models emit audio; do not pass chat/completion Gemini ids.","Populate the model selector from list_engines({ provider: 'gemini' }).","Omit model to accept the safe default."],"tags":["gemini","tts","validation","model","input"],"backgroundTag":null,"analyzedSha":"908ec23eda38526170322c3edf71ba45ecb1ca95","analyzedAt":"2026-08-12T20:53:15.911Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}