{"record":{"id":"1a76fd6681650796","repo":"remotion-dev/remotion","slug":"invert-must-be-a-boolean-but-got-json-stringi","errorCode":null,"errorMessage":"\"invert\" must be a boolean, but got ${JSON.stringify(params.invert)}","messagePattern":"\"invert\" must be a boolean, but got (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/effects/src/mirror/index.ts","lineNumber":82,"sourceCode":"\tinvert: p.invert ?? false,\n});\n\nconst validateMirrorParams = (params: MirrorParams): void => {\n\tassertEffectParamsObject(params, 'Mirror');\n\tassertOptionalFiniteNumber(params.position, 'position');\n\n\tif (\n\t\tparams.direction !== undefined &&\n\t\tparams.direction !== 'horizontal' &&\n\t\tparams.direction !== 'vertical'\n\t) {\n\t\tthrow new TypeError(\n\t\t\t`\"direction\" must be \"horizontal\" or \"vertical\", but got ${JSON.stringify(params.direction)}`,\n\t\t);\n\t}\n\n\tif (params.invert !== undefined && typeof params.invert !== 'boolean') {\n\t\tthrow new TypeError(\n\t\t\t`\"invert\" must be a boolean, but got ${JSON.stringify(params.invert)}`,\n\t\t);\n\t}\n\n\tconst {position} = resolve(params);\n\tvalidateUnitInterval(position, 'position');\n};\n\nexport const mirror = createEffect<MirrorParams, MirrorState>({\n\ttype: 'dev.remotion.effects.mirror',\n\tlabel: 'mirror()',\n\tdocumentationLink: 'https://www.remotion.dev/docs/effects/mirror',\n\tbackend: 'webgl2',\n\tcalculateKey: (params) => {\n\t\tconst r = resolve(params);\n\t\treturn `mirror-${r.direction}-${r.position}-${r.invert ? 1 : 0}`;\n\t},\n\tsetup: (target) => setupMirror(target),","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/mirror/index.ts#L64-L100","documentation":"The mirror() effect's optional `invert` prop controls which side of the image is mirrored. validateMirrorParams throws this TypeError when `invert` is provided (not undefined) but is not a JavaScript boolean. The TypeScript type MirrorParams marks invert as `boolean | undefined`, so this fires only when runtime values bypass type checking — e.g. deserialized JSON, URL params, or form inputs that produce strings/numbers.","triggerScenarios":"Calling mirror({ invert: 'true' }) (string), mirror({ invert: 1 }) (number), mirror({ invert: null }), or mirror({ invert: 'false' }). Any value that is not literally `true` or `false` and not `undefined` triggers it.","commonSituations":"Loading effect parameters from a JSON config file or localStorage where booleans serialize to strings; reading values from HTML form inputs (which always yield strings); passing query-string parameters; dynamic interpolation that produces non-boolean results.","solutions":["Ensure invert is a native JavaScript boolean — mirror({ invert: true }) or mirror({ invert: false }) — not a string or number.","If the value comes from JSON or a URL param, coerce explicitly: mirror({ invert: value === true || value === 'true' }).","Omit invert entirely if you want the default (false): mirror({ direction: 'horizontal' }).","Check the upstream source of the value — DOM inputs and URLSearchParams always return strings."],"exampleFix":"// before\nmirror({ invert: 'true' })\nmirror({ invert: 1 })\n\n// after\nmirror({ invert: true })\nmirror({ invert: Boolean(parsedValue) })","handlingStrategy":"validation","validationCode":"// Before calling mirror(), verify invert is a boolean or undefined\nif (params.invert !== undefined && typeof params.invert !== 'boolean') {\n  throw new Error(`invert must be a boolean, got ${typeof params.invert}`);\n}\nconst result = mirror(params);","typeGuard":"const isMirrorParams = (p: unknown): p is MirrorParams => {\n  if (typeof p !== 'object' || p === null) return false;\n  const obj = p as Record<string, unknown>;\n  if (obj.invert !== undefined && typeof obj.invert !== 'boolean') return false;\n  return true;\n};","tryCatchPattern":null,"preventionTips":["Use the MirrorParams TypeScript type so the compiler rejects non-boolean invert values.","When loading effect params from JSON, URL params, or form inputs, coerce booleans explicitly before passing to mirror().","Avoid passing raw deserialized objects directly to effects without type checking."],"tags":["validation","typescript","mirror-effect","params","typeerror"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}