{"record":{"id":"e86cd1641fb6d097","repo":"remotion-dev/remotion","slug":"effect-config-must-contain-only-finite-json-values","errorCode":null,"errorMessage":"Effect config must contain only finite JSON values","messagePattern":"Effect config must contain only finite JSON values","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/studio-protocol/src/effect-drag-data.ts","lineNumber":40,"sourceCode":"\t};\n};\n\nconst effectConfigSchema = z.record(z.string(), z.json());\nconst effectDragDataSchema = z.object({\n\ttype: z.literal('remotion-effect'),\n\tversion: z.literal(1),\n\teffect: z.object({\n\t\tname: z.string(),\n\t\timportPath: z.string(),\n\t\tconfig: effectConfigSchema,\n\t}),\n});\n\nexport const makeEffectDragData = (\n\teffect: EffectDragData['effect'],\n): EffectDragData => {\n\tif (!z.safeParse(effectConfigSchema, effect.config).success) {\n\t\tthrow new TypeError('Effect config must contain only finite JSON values');\n\t}\n\n\treturn {\n\t\ttype: 'remotion-effect',\n\t\tversion: 1,\n\t\teffect,\n\t};\n};\n\nexport const parseEffectDragData = (value: string): EffectDragData | null => {\n\ttry {\n\t\tconst parsed = z.safeParse(effectDragDataSchema, JSON.parse(value));\n\t\tif (!parsed.success) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn makeEffectDragData({\n\t\t\tname: parsed.data.effect.name,","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/remotion-dev/remotion/blob/a6a7485a9aeb04219510fbe4874f8941486424df/packages/studio-protocol/src/effect-drag-data.ts#L22-L58","documentation":"makeEffectDragData builds the drag payload for an effect and validates that the effect's config is a plain record containing only finite, JSON-safe values using the effectConfigSchema (z.record of z.json from zod/mini). Values like NaN, Infinity, undefined, functions, or class instances are not finite JSON and would break serialization for drag-and-drop, so a TypeError is thrown.","triggerScenarios":"Calling makeEffectDragData with an effect whose config contains non-JSON-safe values: NaN or Infinity numbers, undefined values, functions, Symbols, or non-plain objects.","commonSituations":"Effect props computed from division by zero or Math operations producing NaN/Infinity; passing live React state objects with functions; effect configs built from parsed data that kept undefined entries.","solutions":["Sanitize the config before calling: replace NaN/Infinity with null or a finite sentinel and strip undefined/non-plain values","Validate the config against the JSON schema yourself and surface a friendly message","Clone the config through JSON.parse(JSON.stringify(...)) with a reviver that removes invalid values"],"exampleFix":"// before\nmakeEffectDragData({name: 'Blur', importPath: 'x', config: {amount: NaN}});\n// after\nmakeEffectDragData({name: 'Blur', importPath: 'x', config: {amount: Number.isFinite(amount) ? amount : 0}});","handlingStrategy":"validation","validationCode":"import * as z from 'zod/mini';\nconst cfg = z.safeParse(effectConfigSchema, effect.config);\nif (!cfg.success) throw new Error('Effect config has non-JSON values: ' + JSON.stringify(cfg.error.issues));","typeGuard":"const isFiniteJson = (v: unknown): boolean =>\n  v === null || typeof v === 'string' || typeof v === 'boolean' ||\n  (typeof v === 'number' && Number.isFinite(v)) ||\n  (Array.isArray(v) && v.every(isFiniteJson)) ||\n  (typeof v === 'object' && v !== null && Object.values(v).every(isFiniteJson));","tryCatchPattern":"try {\n  const data = makeEffectDragData(effect);\n} catch (e) {\n  if (e instanceof TypeError && String(e).includes('finite JSON values')) {\n    effect.config = sanitizeConfig(effect.config); // replace NaN/Infinity, strip undefined\n  } else throw e;\n}","preventionTips":["Sanitize numeric props with Number.isFinite before building configs","Strip undefined/functions from configs with a JSON round-trip","Validate configs against the effectConfigSchema at effect-creation time, not drag time"],"tags":["validation","serialization","zod"],"backgroundTag":"non-json-safe-value","analyzedSha":"a6a7485a9aeb04219510fbe4874f8941486424df","analyzedAt":"2026-09-02T16:25:19.997Z","contentChangedAt":"2026-09-02T16:25:19.997Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}