remotion-dev/remotion · error · TypeError

doSample must be a boolean.

Error message

doSample must be a boolean.

What it means

transcribe() validates the decoding option doSample, which switches between sampling and greedy decoding, requiring a strict boolean. Non-boolean inputs are rejected before any model work, following the forceFullSequences check.

Source

Thrown at packages/whisper-webgpu/src/transcribe.ts:87

		);
	}

	if (
		!Number.isFinite(strideLengthInSeconds) ||
		strideLengthInSeconds < 0 ||
		strideLengthInSeconds * 2 >= chunkLengthInSeconds
	) {
		throw new Error(
			'strideLengthInSeconds must be a finite, non-negative number and less than half of chunkLengthInSeconds.',
		);
	}

	if (typeof forceFullSequences !== 'boolean') {
		throw new TypeError('forceFullSequences must be a boolean.');
	}

	if (typeof doSample !== 'boolean') {
		throw new TypeError('doSample must be a boolean.');
	}

	if (!Number.isFinite(temperature) || temperature <= 0) {
		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.');

View on GitHub (pinned to b2f4e34732)

Solutions

  1. Pass doSample: true or false explicitly
  2. Convert config values: doSample: Boolean(raw) or raw === 'true'
  3. Check that the option object is complete and not spread from a partial source

Example fix

// before
await transcribe({doSample: 'false'});
// after
await transcribe({doSample: false});
Defensive patterns

Strategy: type-guard

Validate before calling

if (typeof doSample !== 'boolean') throw new Error('doSample must be a boolean');

Type guard

const isBool = (v: unknown): v is boolean => typeof v === 'boolean';

Try / catch

try {
  await transcribe(options);
} catch (e) {
  if (e instanceof TypeError && e.message.startsWith('doSample')) {
    options.doSample = options.doSample === 'true';
  } else throw e;
}

Prevention

When it happens

Trigger: Passing doSample as undefined, a string ('false'), or a number (0/1); constructing options from JSON/CLI input without boolean conversion.

Common situations: Sampling options persisted in a config file as strings; UI checkbox values bound to 'on'/'off' strings; missing key in a partially-built options object.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


AI-assisted analysis of remotion-dev/remotion@b2f4e34732 (2026-09-09). Data as JSON: /api/errors/4c5f7fa8a9b60e5c. Report an issue: GitHub.