{"record":{"id":"0cdcd495ee78bfa6","repo":"remotion-dev/remotion","slug":"name-must-be-a-boolean-but-got-json-string-0cdcd4","errorCode":null,"errorMessage":"\"${name}\" must be a boolean, but got ${JSON.stringify(value)}","messagePattern":"\"(.+?)\" must be a boolean, but got (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/effects/src/validate-effect-param.ts","lineNumber":45,"sourceCode":"\t\t);\n\t}\n};\n\nexport const assertOptionalColor = (value: unknown, name: string): void => {\n\tif (value === undefined) {\n\t\treturn;\n\t}\n\n\tassertRequiredColor(value, name);\n};\n\nexport const assertOptionalBoolean = (value: unknown, name: string): void => {\n\tif (value === undefined) {\n\t\treturn;\n\t}\n\n\tif (typeof value !== 'boolean') {\n\t\tthrow new TypeError(\n\t\t\t`\"${name}\" must be a boolean, but got ${JSON.stringify(value)}`,\n\t\t);\n\t}\n};\n","sourceCodeStart":27,"sourceCodeEnd":50,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/validate-effect-param.ts#L27-L50","documentation":"Thrown by assertOptionalBoolean when a parameter is provided (not undefined) but is not a boolean. This validator is used by effects with optional boolean toggles: lines, waves, checkerboard, contour-lines, gridlines, and halftone-linear-gradient (typically for maskToSourceAlpha). Undefined is allowed and skips validation; any other non-boolean type triggers the error.","triggerScenarios":"Passing maskToSourceAlpha: 1 instead of maskToSourceAlpha: true; passing maskToSourceAlpha: 'yes'; passing maskToSourceAlpha: null (null is not undefined, so it fails the typeof boolean check).","commonSituations":"Config or API data uses 0/1 or 'true'/'false' strings instead of actual booleans; JSON from an external source where the field is null rather than omitted; developer assumes truthy values are accepted.","solutions":["Pass an actual boolean: lines({colors: [...], maskToSourceAlpha: true})","If omitting the toggle, remove the field or set to undefined — not null or 0","Coerce config values: Boolean(value) if you know the source uses 0/1 or strings","Filter out null before passing: const params = raw.maskToSourceAlpha == null ? {} : {maskToSourceAlpha: Boolean(raw.maskToSourceAlpha)}"],"exampleFix":"// before\nconst e = lines({colors: ['#fff'], maskToSourceAlpha: 1});\n\n// after\nconst e = lines({colors: ['#fff'], maskToSourceAlpha: true});","handlingStrategy":"validation","validationCode":"function isOptionalBoolean(value: unknown): boolean {\n  return value === undefined || typeof value === 'boolean';\n}\n\n// Before calling:\nif (!isOptionalBoolean(params.maskToSourceAlpha)) {\n  throw new Error('maskToSourceAlpha must be a boolean or omitted');\n}\nconst e = lines(params);","typeGuard":"function isOptionalBoolean(value: unknown): value is boolean | undefined {\n  return value === undefined || typeof value === 'boolean';\n}","tryCatchPattern":null,"preventionTips":["Pass actual booleans (true/false), never 0/1 or 'true'/'false' strings","Omit optional boolean fields entirely if you do not need to set them — do not pass null","Coerce 0/1 or string values with Boolean() before passing to effects","Filter null from external data: use undefined in its place for optional fields"],"tags":["validation","typescript","params","typeerror","boolean","shared-helper"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}