remotion-dev/remotion · error · Error

Value must be a string, but is ${JSON.stringify(value)}

Error message

Value must be a string, but is ${JSON.stringify(value)}

What it means

Thrown by findPropsToDelete when the `value` argument is not a string. Interactive enum variants are keyed by strings, so the function refuses non-string values (numbers, objects, undefined) before looking up the variant.

Source

Thrown at packages/core/src/find-props-to-delete.ts:19

import type {InteractivitySchema} from './internals';

export const findPropsToDelete = ({
	schema,
	key,
	value,
}: {
	schema: InteractivitySchema;
	key: string;
	value: unknown;
}) => {
	const fieldSchema = schema[key];

	if (!fieldSchema) {
		throw new Error('Key ' + JSON.stringify(key) + ' not found in schema');
	}

	if (typeof value !== 'string') {
		throw new Error('Value must be a string, but is ' + JSON.stringify(value));
	}

	if (fieldSchema.type !== 'enum') {
		throw new Error('Key ' + JSON.stringify(key) + ' is not an enum');
	}

	const currentVariant = fieldSchema.variants[value as string];
	if (!currentVariant) {
		throw new Error(
			'Value for ' +
				JSON.stringify(key) +
				' must be one of ' +
				Object.keys(fieldSchema.variants)
					.map((v) => JSON.stringify(v))
					.join(', ') +
				', got ' +
				JSON.stringify(value),
		);

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Coerce or select the string variant key before calling: pass `String(value)` only if you are certain it names a variant, otherwise map the value to its variant name.
  2. Add a runtime check `if (typeof value !== 'string') return;` at the caller.
  3. Inspect the call site for undefined caused by bad destructuring or missing map keys.
  4. Type the caller's value as string so TypeScript flags the misuse at compile time.

Example fix

// before
findPropsToDelete({schema, key: 'size', value: 2});

// after
findPropsToDelete({schema, key: 'size', value: 'large'});
Defensive patterns

Strategy: type-guard

Validate before calling

if (typeof value !== 'string') {
  throw new TypeError(`value must be a string variant, got ${typeof value}`);
}
findPropsToDelete({schema, key, value});

Type guard

function isStringVariant(value: unknown): value is string {
  return typeof value === 'string';
}

Prevention

When it happens

Trigger: Calling findPropsToDelete with value being a number, boolean, null, undefined, or object — e.g. passing a raw numeric variant id instead of its string key.

Common situations: Loosely-typed callers (plain JS, deserialized JSON with coerced types) feeding a number where a variant string is expected; off-by-one in destructuring that yields undefined.

Related errors


AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12). Data as JSON: /api/errors/760b41557623a76e. Report an issue: GitHub.