{"record":{"id":"c1edf0e2b3a879ef","repo":"remotion-dev/remotion","slug":"scale-must-be-greater-than-0","errorCode":null,"errorMessage":"Scale must be greater than 0","messagePattern":"Scale must be greater than 0","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/convert/app/lib/calculate-new-dimensions-from-dimensions.ts","lineNumber":65,"sourceCode":"\t\t\t},\n\t\t\tneedsToBeMultipleOfTwo,\n\t\t});\n\t}\n\n\tif (resizeOperation.mode === 'max-width') {\n\t\tconst width = Math.min(dimensions.width, resizeOperation.maxWidth);\n\t\treturn ensureMultipleOfTwo({\n\t\t\tdimensions: {\n\t\t\t\twidth,\n\t\t\t\theight: Math.round((width / dimensions.width) * dimensions.height),\n\t\t\t},\n\t\t\tneedsToBeMultipleOfTwo,\n\t\t});\n\t}\n\n\tif (resizeOperation.mode === 'scale') {\n\t\tif (resizeOperation.scale <= 0) {\n\t\t\tthrow new Error('Scale must be greater than 0');\n\t\t}\n\n\t\tconst width = Math.round(dimensions.width * resizeOperation.scale);\n\t\tconst height = Math.round(dimensions.height * resizeOperation.scale);\n\t\treturn ensureMultipleOfTwo({\n\t\t\tdimensions: {\n\t\t\t\twidth,\n\t\t\t\theight,\n\t\t\t},\n\t\t\tneedsToBeMultipleOfTwo,\n\t\t});\n\t}\n\n\tthrow new Error('Invalid resizing mode ' + (resizeOperation satisfies never));\n};\n\nexport const normalizeVideoRotation = (rotation: number) => {\n\treturn ((rotation % 360) + 360) % 360;","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/convert/app/lib/calculate-new-dimensions-from-dimensions.ts#L47-L83","documentation":"Thrown by calculateNewSizeAfterResizing when resizeOperation.mode === 'scale' and the supplied scale is <= 0. The function multiplies width/height by scale, so a zero or negative scale would produce invalid (zero or negative) dimensions.","triggerScenarios":"Passing a MediabunnyResize of mode 'scale' with scale = 0, a negative number, or NaN (NaN <= 0 is false but yields NaN dims elsewhere). Direct misuse of the resize API or a UI control that allows zero/negative scale values.","commonSituations":"A slider bound to scale that can reach zero; deserialized config with a missing/zeroed scale field; division or parsing that yields a negative scale.","solutions":["Clamp the scale input to a small positive minimum (e.g. 0.01) before constructing the resize operation.","Validate the resize config at the form/UI boundary so scale must be a positive finite number.","Default scale to 1 when the field is missing or invalid."],"exampleFix":"// before\nconst scale = Number(userInput); // 0 or negative allowed\nresizeOperation = {mode: 'scale', scale};\n\n// after\nconst scale = Math.max(0.01, Number(userInput) || 1);\nif (!Number.isFinite(scale) || scale <= 0) {\n  throw new Error('Scale must be a positive number');\n}\nresizeOperation = {mode: 'scale', scale};","handlingStrategy":"validation","validationCode":"function isValidScale(scale: number): boolean {\n  return Number.isFinite(scale) && scale > 0;\n}\nif (!isValidScale(resizeOperation.scale)) throw new Error('Scale must be a positive finite number');","typeGuard":"function isValidResize(op: MediabunnyResize | null): boolean {\n  if (!op) return true;\n  if (op.mode === 'scale') return Number.isFinite(op.scale) && op.scale > 0;\n  return true;\n}","tryCatchPattern":"try {\n  return calculateNewSizeAfterResizing({...});\n} catch (e) {\n  if (e.message === 'Scale must be greater than 0') return dimensions; // ignore resize\n  throw e;\n}","preventionTips":["Clamp scale inputs at the UI boundary to a positive minimum.","Validate serialized resize config on load.","Default missing scale fields to 1."],"tags":["typescript","convert","resize","validation","dimensions"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}