remotion-dev/remotion · error · TypeError
task must be either "transcribe" or "translate".
Error message
task must be either "transcribe" or "translate".
What it means
transcribe() validates the task option against the only two supported values, 'transcribe' and 'translate'. Any other string is rejected with a TypeError before the model info is consulted; passing an unsupported task would otherwise fail inside the model pipeline.
Source
Thrown at packages/whisper-webgpu/src/transcribe.ts:109
throw new TypeError('temperature must be a finite number greater than 0.');
}
if (!Number.isInteger(topK) || topK < 0) {
throw new TypeError('topK must be a non-negative integer.');
}
if (!Number.isFinite(repetitionPenalty) || repetitionPenalty <= 0) {
throw new TypeError(
'repetitionPenalty must be a finite number greater than 0.',
);
}
if (!Number.isInteger(noRepeatNgramSize) || noRepeatNgramSize < 0) {
throw new TypeError('noRepeatNgramSize must be a non-negative integer.');
}
if (task !== 'transcribe' && task !== 'translate') {
throw new TypeError('task must be either "transcribe" or "translate".');
}
const {multilingual, supportsTranslation} = getModelInfo(model);
if (task === 'translate' && !supportsTranslation) {
throw new Error(`The model "${model}" does not support translation.`);
}
if (multilingual && (language === undefined || language === 'auto')) {
throw new Error(
`The language option is required for the multilingual model "${model}" because automatic language detection is not supported.`,
);
}
if (
!multilingual &&
language !== undefined &&
language !== 'auto' &&
language !== 'en' &&View on GitHub (pinned to b2f4e34732)
Solutions
- Pass exactly 'transcribe' or 'translate' (lowercase)
- Normalize user input with toLowerCase() and map synonyms ('translation' -> 'translate')
- Explicitly set task instead of relying on it being optional
Example fix
// before
await transcribe({task: 'TRANSCRIBE'});
// after
const task = rawTask.toLowerCase() === 'translate' ? 'translate' : 'transcribe';
await transcribe({task}); Defensive patterns
Strategy: type-guard
Validate before calling
const tasks = ['transcribe', 'translate'] as const;
if (!tasks.includes(task as any)) throw new Error(`task must be one of ${tasks.join(', ')}`); Type guard
const isTask = (t: unknown): t is 'transcribe' | 'translate' => t === 'transcribe' || t === 'translate';
Try / catch
try {
await transcribe(options);
} catch (e) {
if (e instanceof TypeError && e.message.includes('task')) {
options.task = 'transcribe';
} else throw e;
} Prevention
- Use the exported union type instead of plain strings
- Normalize user-facing labels to lowercase before mapping to task
- Provide UI selects limited to the two valid values
When it happens
Trigger: Passing task: 'TRANSCRIBE' (wrong casing), task: 'translation', or leaving task undefined while the code assumes a default.
Common situations: Mapping user-facing UI labels to task values without normalization; options read from config keys with different naming; forgetting the option is required, not defaulted.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- "${name}" must be one of ${variants.join(', ')}
- Value for ${JSON.stringify(key)} must be one of ${Object.key
- The "${name}" prop ${location} must be one of ${validCodecs.
- "${name}" must be ${formatEnum(variants)}, but got ${JSON.st
- "${name}" must be ${formatEnum(variants)}
AI-assisted analysis of remotion-dev/remotion@b2f4e34732 (2026-09-09).
Data as JSON: /api/errors/2aa60c713da29278.
Report an issue: GitHub.