{"record":{"id":"b3115b685d11f6ad","repo":"remotion-dev/remotion","slug":"could-not-serialize-the-visual-control-value","errorCode":null,"errorMessage":"Could not serialize the visual control value","messagePattern":"Could not serialize the visual control value","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/studio-codemods/src/apply-visual-control.ts","lineNumber":83,"sourceCode":"\n\t\t\tconst firstArgument = node.arguments[0];\n\t\t\tconst str = expectString(firstArgument);\n\t\t\tconst matchingChanges = transformation.changes.filter(\n\t\t\t\t(candidate) => candidate.id === str,\n\t\t\t);\n\t\t\tconst change = matchingChanges.at(-1);\n\t\t\tif (!change) {\n\t\t\t\treturn this.traverse(path);\n\t\t\t}\n\n\t\t\tconst serialized = change.newValueIsUndefined\n\t\t\t\t? 'undefined'\n\t\t\t\t: stringifyDefaultProps({\n\t\t\t\t\t\tprops: JSON.parse(change.newValueSerialized),\n\t\t\t\t\t\tenumPaths: change.enumPaths,\n\t\t\t\t\t});\n\t\t\tif (serialized === undefined) {\n\t\t\t\tthrow new Error('Could not serialize the visual control value');\n\t\t\t}\n\n\t\t\tconst secondArgument = node.arguments[1];\n\t\t\tif (secondArgument) {\n\t\t\t\tif (!secondArgument.loc) {\n\t\t\t\t\tthrow new Error('Could not locate the visual control value');\n\t\t\t\t}\n\n\t\t\t\tconst start = recastLocToOffset(input, secondArgument.loc.start);\n\t\t\t\tconst end = recastLocToOffset(input, secondArgument.loc.end);\n\t\t\t\tconst lineStart = input.lastIndexOf('\\n', start - 1) + 1;\n\t\t\t\tedits.push({\n\t\t\t\t\tstart,\n\t\t\t\t\tend,\n\t\t\t\t\treplacement: formatSerializedValue({\n\t\t\t\t\t\tinput,\n\t\t\t\t\t\tlinePrefix: input.slice(lineStart, start),\n\t\t\t\t\t\tpreviousValue: input.slice(start, end).trim(),","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/remotion-dev/remotion/blob/46a3a6bf13ca367376ff18bbb06dae2e87e0d068/packages/studio-codemods/src/apply-visual-control.ts#L65-L101","documentation":"applyVisualControl() rewrites the second argument of a visualControl() call in source. It serializes the codemod's new value via stringifyDefaultProps; when that serializer returns undefined (it cannot produce a printable value for the given props), the codemod aborts with this error instead of writing a broken replacement.","triggerScenarios":"A transformation.change with newValueIsUndefined=false whose newValueSerialized parses (via JSON.parse) to a props object that stringifyDefaultProps cannot serialize (e.g. an unsupported or empty value shape).","commonSituations":"A Studio codemod payload produced by a newer Remotion version contains a new value kind the local serializer does not understand; manually crafted codemod JSON with an empty or malformed value.","solutions":["Check the change's newValueSerialized / newValueIsUndefined fields and supply a serializable props value","Update @remotion/studio-shared and studio-codemods to matching versions","Apply the value change manually in the source file instead of running the codemod"],"exampleFix":"// before: change = { id: 'my-control', newValueSerialized: '{}', enumPaths: [] }\n// after:   change = { id: 'my-control', newValueSerialized: '\"#ff0000\"', enumPaths: [] }","handlingStrategy":"validation","validationCode":"const props = JSON.parse(change.newValueSerialized);\nif (props === undefined || props === null) throw new Error('Visual control change has no serializable value');","typeGuard":"const isSerializable = (v: unknown) => v !== undefined && (typeof v !== 'object' || v === null || Object.keys(v).length > 0);","tryCatchPattern":"try {\n  applyVisualControl({input, transformation});\n} catch (e) {\n  if ((e as Error).message.includes('Could not serialize the visual control value')) {\n    // fall back to manual edit / re-generate codemod with a valid value\n  }\n}","preventionTips":["Always set a concrete newValueSerialized string when newValueIsUndefined is false","Keep @remotion/studio-shared and studio-codemods versions in sync","Validate codemod JSON payloads before applying them"],"tags":["codemod","serialization","studio"],"backgroundTag":"json-serialization-failed","analyzedSha":"46a3a6bf13ca367376ff18bbb06dae2e87e0d068","analyzedAt":"2026-09-18T00:12:20.256Z","contentChangedAt":"2026-09-18T00:12:20.256Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}