{"record":{"id":"2227d9ce9ab0b36e","repo":"remotion-dev/remotion","slug":"name-must-be-0-but-got-json-stringify-v","errorCode":null,"errorMessage":"\"${name}\" must be >= 0, but got ${JSON.stringify(value)}","messagePattern":"\"(.+?)\" must be >= 0, but got (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/effects/src/color-utils.ts","lineNumber":57,"sourceCode":"\tstep: 1,\n\tdefault: DEFAULT_HUE_DEGREES,\n\tdescription: 'Degrees',\n} as const satisfies InteractivitySchema['degrees'];\n\nexport const assertOptionalFiniteNumber = (\n\tvalue: unknown,\n\tname: string,\n): void => {\n\tif (value === undefined) {\n\t\treturn;\n\t}\n\n\tassertRequiredFiniteNumber(value, name);\n};\n\nexport const validateUnitInterval = (value: number, name: string): void => {\n\tif (value < 0) {\n\t\tthrow new TypeError(\n\t\t\t`\"${name}\" must be >= 0, but got ${JSON.stringify(value)}`,\n\t\t);\n\t}\n\n\tif (value > 1) {\n\t\tthrow new TypeError(\n\t\t\t`\"${name}\" must be <= 1, but got ${JSON.stringify(value)}`,\n\t\t);\n\t}\n};\n\nexport const validateNonNegative = (value: number, name: string): void => {\n\tif (value < 0) {\n\t\tthrow new TypeError(\n\t\t\t`\"${name}\" must be >= 0, but got ${JSON.stringify(value)}`,\n\t\t);\n\t}\n};","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/color-utils.ts#L39-L75","documentation":"Thrown by validateUnitInterval in color-utils.ts when a value resolved to the [0,1] range is below 0. The dynamic name in the message identifies the offending field. For color-correction this covers 'pivot'; for color-key it covers 'similarity', 'smoothness', and 'spillSuppression'. It is a caller-input TypeError.","triggerScenarios":"Reached when colorCorrection({pivot}) gets pivot < 0, or when colorKey({similarity | smoothness | spillSuppression}) gets a value < 0. Validation runs in validateColorCorrectionParams (color-correction.ts:181) or validateColorKeyParams (color-key.ts:107-109) via validateUnitInterval at color-utils.ts:56, before any GL work.","commonSituations":"Animated values from interpolate/Spring that undershoot below 0 without clamping, a value copied from another tool's scale, or a slider whose min was set below 0.","solutions":["Clamp the value to [0,1] before passing it: Math.max(0, Math.min(1, value)).","Use interpolate(..., {extrapolateLeft: 'clamp', extrapolateRight: 'clamp'}) so animation cannot leave the range.","Inspect the field name and value in the error and fix the producer of that number.","Omit the field to accept its documented default (e.g. similarity 0.18, smoothness 0.08, spillSuppression 0.25, pivot 0.5)."],"exampleFix":"// before\ncolorKey({similarity: -0.2}); // throws: similarity must be >= 0\n\n// after\nconst similarity = Math.max(0, Math.min(1, animated));\ncolorKey({similarity});","handlingStrategy":"validation","validationCode":"function assertUnitInterval(value: number | undefined, name: string): number | undefined {\n  if (value === undefined) return value;\n  if (!Number.isFinite(value)) {\n    throw new TypeError(`${name} must be finite, got ${value}`);\n  }\n  if (value < 0 || value > 1) {\n    throw new TypeError(`${name} must be in [0, 1], got ${value}`);\n  }\n  return value;\n}\n\n// colorCorrection({pivot: assertUnitInterval(pivot, 'pivot')})\n// colorKey({\n//   similarity: assertUnitInterval(sim, 'similarity'),\n//   smoothness: assertUnitInterval(smooth, 'smoothness'),\n//   spillSuppression: assertUnitInterval(spill, 'spillSuppression'),\n// })","typeGuard":"const isUnitInterval = (v: unknown): v is number =>\n  typeof v === 'number' && Number.isFinite(v) && v >= 0 && v <= 1;","tryCatchPattern":null,"preventionTips":["Clamp values with Math.max(0, Math.min(1, value)) before passing them.","Use interpolate(..., {extrapolateLeft: 'clamp', extrapolateRight: 'clamp'}) for any driver of these fields.","Remember the field list: pivot (color-correction), similarity/smoothness/spillSuppression (color-key).","Omit a field to accept its documented default instead of risking an out-of-range value."],"tags":["validation","typescript","params","color-utils","unit-interval","color-key","color-correction"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}