{"record":{"id":"e4fe5853cbfeb3f3","repo":"HeyPuter/puter","slug":"invalid-engine","errorCode":"invalid_engine","errorMessage":"Invalid engine: ${engine}. Valid engines: ${VALID_ENGINES.join(', ')}","messagePattern":"Invalid engine: (.+?)\\. Valid engines: (.+?)","errorType":"validation","errorClass":"HttpError","httpStatus":400,"severity":"error","filePath":"src/backend/drivers/ai-tts/providers/awsPolly/AWSPollyTTSProvider.ts","lineNumber":176,"sourceCode":"            v.SupportedEngines?.includes(engine),\n        );\n        return fallback ? fallback.Id : 'Salli';\n    }\n\n    async listVoices(args?: Record<string, unknown>): Promise<ITTSVoice[]> {\n        const engine = args?.engine as string | undefined;\n        const pollyVoices = await this.describeVoices();\n\n        let voices = pollyVoices.Voices;\n\n        if (engine) {\n            if (VALID_ENGINES.includes(engine)) {\n                // eslint-disable-next-line @typescript-eslint/no-explicit-any\n                voices = voices.filter((voice: any) =>\n                    voice.SupportedEngines?.includes(engine),\n                );\n            } else {\n                throw new HttpError(\n                    400,\n                    `Invalid engine: ${engine}. Valid engines: ${VALID_ENGINES.join(', ')}`,\n                    {\n                        legacyCode: 'invalid_engine',\n                        fields: { engine, valid_engines: VALID_ENGINES },\n                    },\n                );\n            }\n        }\n\n        // eslint-disable-next-line @typescript-eslint/no-explicit-any\n        return voices.map((voice: any) => ({\n            id: voice.Id,\n            name: voice.Name,\n            language: {\n                name: voice.LanguageName,\n                code: voice.LanguageCode,\n            },","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/HeyPuter/puter/blob/908ec23eda38526170322c3edf71ba45ecb1ca95/src/backend/drivers/ai-tts/providers/awsPolly/AWSPollyTTSProvider.ts#L158-L194","documentation":"AWSPollyTTSProvider.listVoices filters Polly's voice catalogue by engine. If args.engine is supplied and is not one of VALID_ENGINES ('standard','neural','long-form','generative'), it throws HTTP 400 (legacyCode invalid_engine), echoing the valid set and attaching fields.engine and fields.valid_engines.","triggerScenarios":"Calling list_voices({ provider: 'aws-polly', engine: 'neuronal' }) or any engine string outside VALID_ENGINES. The check runs only when engine is truthy; omitting it returns all voices.","commonSituations":"Typos ('neuronal', 'standard1'); using an AWS Polly engine name that doesn't exist; copy-pasting an engine id from another provider into the Polly voice listing.","solutions":["Pass an engine from VALID_ENGINES: 'standard', 'neural', 'long-form', or 'generative'.","Omit engine to list voices across all engines.","Call list_engines({ provider: 'aws-polly' }) to fetch the valid engine ids dynamically."],"exampleFix":"// before\nawait driver.list_voices({ provider: 'aws-polly', engine: 'neuronal' });\n// after\nawait driver.list_voices({ provider: 'aws-polly', engine: 'neural' });","handlingStrategy":"validation","validationCode":"const VALID_ENGINES = ['standard', 'neural', 'long-form', 'generative'];\n\nfunction listPollyVoices(engine) {\n  if (engine !== undefined && !VALID_ENGINES.includes(engine)) {\n    throw new Error(`engine must be one of ${VALID_ENGINES.join(', ')}`);\n  }\n  return driver.list_voices({ provider: 'aws-polly', engine });\n}","typeGuard":"const VALID_ENGINES = ['standard', 'neural', 'long-form', 'generative'] as const;\ntype PollyEngine = typeof VALID_ENGINES[number];\n\nconst isPollyEngine = (v: unknown): v is PollyEngine =>\n  typeof v === 'string' && (VALID_ENGINES as readonly string[]).includes(v);","tryCatchPattern":null,"preventionTips":["Prefer fetching engines via list_engines({ provider: 'aws-polly' }) over hardcoding.","When engine is optional, leave it undefined to list voices across all engines.","Validate with a shared constant to keep client and server in sync."],"tags":["aws-polly","tts","validation","engine","input"],"backgroundTag":null,"analyzedSha":"908ec23eda38526170322c3edf71ba45ecb1ca95","analyzedAt":"2026-08-12T20:53:15.911Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}