{"record":{"id":"a0a77bde42131cbc","repo":"remotion-dev/remotion","slug":"could-not-serialize-the-updated-defaultprops-value","errorCode":null,"errorMessage":"Could not serialize the updated defaultProps value","messagePattern":"Could not serialize the updated defaultProps value","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/studio-codemods/src/update-default-props.ts","lineNumber":150,"sourceCode":"\t\t\treplaceStart = recastLocToOffset(input, valueLoc.start);\n\t\t\treplaceEnd = recastLocToOffset(input, valueLoc.end);\n\n\t\t\tthis.traverse(path); // Continue traversing the AST\n\t\t},\n\t});\n\n\tif (replaceStart === undefined || replaceEnd === undefined) {\n\t\tthrow new Error(\n\t\t\t`Could not find defaultProps for composition \"${compositionId}\"`,\n\t\t);\n\t}\n\n\t// linePrefix includes the JSX container opening brace\n\tconst lineStart = input.lastIndexOf('\\n', replaceStart) + 1;\n\tconst linePrefix = input.substring(lineStart, replaceStart + 1);\n\tconst previousValue = input.slice(replaceStart + 1, replaceEnd - 1).trim();\n\tif (stringified === undefined) {\n\t\tthrow new Error('Could not serialize the updated defaultProps value');\n\t}\n\n\tconst formatted = formatSerializedValue({\n\t\tinput,\n\t\tlinePrefix,\n\t\tpreviousValue,\n\t\tserialized: stringified,\n\t});\n\n\t// Replace the JSX expression container in the original input\n\tconst output =\n\t\tinput.substring(0, replaceStart) +\n\t\t'{' +\n\t\tformatted +\n\t\t'}' +\n\t\tinput.substring(replaceEnd);\n\n\treturn {output};","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/remotion-dev/remotion/blob/46a3a6bf13ca367376ff18bbb06dae2e87e0d068/packages/studio-codemods/src/update-default-props.ts#L132-L168","documentation":"updateDefaultProps throws this when the serialized replacement for the defaultProps object is undefined — i.e. JSON.stringify-style serialization produced no output. This happens when the new defaultProps value cannot be represented as JSON (undefined root, functions, or circular references), so the codemod cannot write it back into the <Composition> source.","triggerScenarios":"Calling updateDefaultProps with a defaultProps value containing undefined at the top level, functions, class instances, or circular references that the serializer cannot stringify.","commonSituations":"Studio prop editing where props contain non-JSON values (e.g. a component reference, a Date-like object, a Map/Set), or generated default props that include undefined keys instead of null.","solutions":["Ensure the updated defaultProps value is a JSON-serializable plain object (no undefined/functions/circular refs)","Replace undefined values with null or omit those keys","Pass a plain object literal rather than a class instance or function-returning value","Check the props editor output in Studio for non-JSON values before saving"],"exampleFix":"// before\nconst nextProps = {videoSrc: getSrc(), onDone: handleDone}; // function + maybe undefined\nupdateDefaultProps({input, compositionId, defaultProps: nextProps});\n// after\nconst nextProps = {videoSrc: 'https://example.com/video.mp4'};\nupdateDefaultProps({input, compositionId, defaultProps: nextProps});","handlingStrategy":"validation","validationCode":"const isJsonSerializable = (v: unknown): boolean => {\n  try { JSON.stringify(v); return true; } catch { return false; }\n};\nif (!isJsonSerializable(nextProps) || nextProps === undefined) throw new Error('defaultProps must be a JSON-serializable object');","typeGuard":"const isPlainProps = (v: unknown): v is Record<string, unknown> =>\n  v !== null && typeof v === 'object' && !Array.isArray(v) &&\n  Object.values(v).every((x) => x === null || ['string','number','boolean'].includes(typeof x));","tryCatchPattern":"try {\n  const {output} = updateDefaultProps({input, compositionId, defaultProps});\n} catch (e) {\n  if (e instanceof Error && e.message.includes('Could not serialize')) {\n    const safe = JSON.parse(JSON.stringify(defaultProps, (_k, v) => v === undefined ? null : v));\n    return updateDefaultProps({input, compositionId, defaultProps: safe});\n  }\n  throw e;\n}","preventionTips":["Keep defaultProps values JSON-compatible (no functions, undefined, class instances, circular refs)","Replace undefined values with null or omit keys","Sanitize runtime-generated props before writing them into source"],"tags":["serialization","json","default-props"],"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"}