{"record":{"id":"170129152d535f48","repo":"remotion-dev/remotion","slug":"value-for-json-stringify-key-must-be-one-of","errorCode":null,"errorMessage":"Value for ${JSON.stringify(key)} must be one of ${Object.keys(fieldSchema.variants).map((v) => JSON.stringify(v)).join(', ')}, got ${JSON.stringify(value)}","messagePattern":"Value for (.+?) must be one of (.+?), got (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/find-props-to-delete.ts","lineNumber":28,"sourceCode":"\tvalue: unknown;\n}) => {\n\tconst fieldSchema = schema[key];\n\n\tif (!fieldSchema) {\n\t\tthrow new Error('Key ' + JSON.stringify(key) + ' not found in schema');\n\t}\n\n\tif (typeof value !== 'string') {\n\t\tthrow new Error('Value must be a string, but is ' + JSON.stringify(value));\n\t}\n\n\tif (fieldSchema.type !== 'enum') {\n\t\tthrow new Error('Key ' + JSON.stringify(key) + ' is not an enum');\n\t}\n\n\tconst currentVariant = fieldSchema.variants[value as string];\n\tif (!currentVariant) {\n\t\tthrow new Error(\n\t\t\t'Value for ' +\n\t\t\t\tJSON.stringify(key) +\n\t\t\t\t' must be one of ' +\n\t\t\t\tObject.keys(fieldSchema.variants)\n\t\t\t\t\t.map((v) => JSON.stringify(v))\n\t\t\t\t\t.join(', ') +\n\t\t\t\t', got ' +\n\t\t\t\tJSON.stringify(value),\n\t\t);\n\t}\n\n\tconst otherVariants = Object.keys(fieldSchema.variants).filter(\n\t\t(v) => v !== value,\n\t);\n\n\tconst otherKeys = new Set<string>();\n\tfor (const variant of otherVariants) {\n\t\tconst otherVariant = fieldSchema.variants[variant];","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/core/src/find-props-to-delete.ts#L10-L46","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nfindPropsToDelete({schema, key: 'theme', value: 'drak'}); // typo\n\n// after\nconst variants = Object.keys(schema.theme.variants);\nconst value = variants.includes(raw) ? raw : variants[0];\nfindPropsToDelete({schema, key: 'theme', value});","handlingStrategy":"validation","validationCode":"const variants = Object.keys(schema[key].variants);\nif (!variants.includes(value)) {\n  console.warn(`Variant ${value} not in ${variants.join(', ')}`);\n  return;\n}\nfindPropsToDelete({schema, key, value});","typeGuard":"function isValidVariant(field: {variants: Record<string, unknown>}, value: string): boolean {\n  return Object.prototype.hasOwnProperty.call(field.variants, value);\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["interactivity","schema","validation","enum"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}