remotion-dev/remotion · error · Error
Value for ${JSON.stringify(key)} must be one of ${Object.key
Error message
Value for ${JSON.stringify(key)} must be one of ${Object.keys(fieldSchema.variants).map((v) => JSON.stringify(v)).join(', ')}, got ${JSON.stringify(value)} What it means
Thrown by findPropsToDelete when the schema field is an enum but `value` is not one of its declared variant keys. The error enumerates the accepted variant names so the caller can correct the value.
Source
Thrown at packages/core/src/find-props-to-delete.ts:28
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),
);
}
const otherVariants = Object.keys(fieldSchema.variants).filter(
(v) => v !== value,
);
const otherKeys = new Set<string>();
for (const variant of otherVariants) {
const otherVariant = fieldSchema.variants[variant];View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Match the value against Object.keys(schema[key].variants) before calling.
- If the variant was renamed, migrate stored state to the new variant name.
- Restore the missing variant in the schema if it should still exist.
- Treat an unknown variant as 'no-op' at the caller if deletion of an absent variant is harmless.
Example fix
// before
findPropsToDelete({schema, key: 'theme', value: 'drak'}); // typo
// after
const variants = Object.keys(schema.theme.variants);
const value = variants.includes(raw) ? raw : variants[0];
findPropsToDelete({schema, key: 'theme', value}); Defensive patterns
Strategy: validation
Validate before calling
const variants = Object.keys(schema[key].variants);
if (!variants.includes(value)) {
console.warn(`Variant ${value} not in ${variants.join(', ')}`);
return;
}
findPropsToDelete({schema, key, value}); Type guard
function isValidVariant(field: {variants: Record<string, unknown>}, value: string): boolean {
return Object.prototype.hasOwnProperty.call(field.variants, value);
} Prevention
- When renaming/removing a variant, migrate persisted state in the same change.
- Validate user-supplied variant strings against the schema before use.
- Treat unknown variants as no-ops when deletion would be harmless.
When it happens
Trigger: Passing a variant string that is not a key of fieldSchema.variants — e.g. a typo, a removed variant, or a value from a different schema version.
Common situations: Editing a schema to remove/rename a variant while persisted state still references the old name; user-supplied variant strings that have not been validated.
Related errors
- Key ${JSON.stringify(key)} not found in schema
- Value must be a string, but is ${JSON.stringify(value)}
- Key ${JSON.stringify(key)} is not an enum
- "${name}" must be one of ${variants.join(', ')}
- The "${name}" prop ${location} must be one of ${validCodecs.
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/170129152d535f48.
Report an issue: GitHub.