{"record":{"id":"adf36965d347f3bd","repo":"remotion-dev/remotion","slug":"wavelength-must-be-0-but-got-json-stringify","errorCode":null,"errorMessage":"\"wavelength\" must be > 0, but got ${JSON.stringify(resolved.wavelength)}","messagePattern":"\"wavelength\" must be > 0, but got (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/effects/src/wave/index.ts","lineNumber":109,"sourceCode":"\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\tconst resolved = resolve(params);\n\tif (resolved.amplitude < 0) {\n\t\tthrow new TypeError(\n\t\t\t`\"amplitude\" must be >= 0, but got ${JSON.stringify(resolved.amplitude)}`,\n\t\t);\n\t}\n\n\tif (resolved.wavelength <= 0) {\n\t\tthrow new TypeError(\n\t\t\t`\"wavelength\" must be > 0, but got ${JSON.stringify(resolved.wavelength)}`,\n\t\t);\n\t}\n};\n\n// Sine wave warp: displaces source UVs along the propagation axis. WebGL2 only.\nexport const wave = createEffect<WaveParams, WaveState>({\n\ttype: 'dev.remotion.effects.wave',\n\tlabel: 'wave()',\n\tdocumentationLink: 'https://www.remotion.dev/docs/effects/wave',\n\tbackend: 'webgl2',\n\tcalculateKey: (params) => {\n\t\tconst r = resolve(params);\n\t\treturn `wave-${r.phase}-${r.direction}-${r.amplitude}-${r.wavelength}`;\n\t},\n\tsetup: (target) => setupWave(target),\n\tapply: ({source, width, height, params, state}) => {\n\t\tconst r = resolve(params);","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/wave/index.ts#L91-L127","documentation":"TypeError thrown by wave's validateWaveParams when the resolved wavelength is <= 0. The check uses the resolved value (default 240), so it triggers only when an explicit zero or negative number is passed. assertOptionalFiniteNumber runs first, so non-numbers/NaN/Infinity are rejected earlier with a different message.","triggerScenarios":"Calling wave({wavelength: 0}), wave({wavelength: -50}), or passing a computed wavelength that lands at or below zero (e.g. a frame-based formula that decreases through zero). A wavelength of zero is mathematically invalid for the sine warp.","commonSituations":"Animation formulas that shrink wavelength toward/through zero; division-based derivations that yield zero; passing a value intended for a different parameter.","solutions":["Pass wavelength > 0 (a small positive floor like 1, or clamp with Math.max(1, value)).","For frame-driven wavelength, clamp with Math.max(MIN_WAVELENGTH, value).","If you want to flatten the wave, reduce amplitude to 0 rather than wavelength.","Type wavelength as a positive number and assert it at the source."],"exampleFix":"// before - derived wavelength crosses zero\nconst e = wave({wavelength: 240 - frame}); // hits 0 and below\n\n// after - keep it strictly positive\nconst e = wave({wavelength: Math.max(1, 240 - frame)});","handlingStrategy":"validation","validationCode":"import {wave} from '@remotion/effects';\n\nconst MIN_WAVELENGTH = 1;\nconst clampWavelength = (value: number): number => {\n  if (!Number.isFinite(value)) {\n    throw new TypeError(`wavelength must be a finite number, got ${value}`);\n  }\n  return Math.max(MIN_WAVELENGTH, value);\n};\n\nconst wavelength = clampWavelength(rawWavelength);\nconst e = wave({amplitude: 60, wavelength});","typeGuard":"const isPositiveFinite = (v: unknown): v is number =>\n  typeof v === 'number' && Number.isFinite(v) && v > 0;","tryCatchPattern":"try {\n  const e = wave({amplitude: 60, wavelength: rawWavelength});\n} catch (err) {\n  if (err instanceof TypeError) {\n    console.error('Invalid wave wavelength:', rawWavelength, err);\n  }\n  throw err;\n}","preventionTips":["Clamp frame-derived wavelength with Math.max(1, value) to stay strictly positive.","Reduce amplitude to 0 to flatten the wave rather than shrinking wavelength to/below 0.","Guard division-based derivations that could yield zero.","Type wavelength as a positive number and assert at the source."],"tags":["validation","params","wave","range"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}