{"record":{"id":"f5c38d5c2965c929","repo":"remotion-dev/remotion","slug":"width-and-height-must-be-numbers-between-0-and-m","errorCode":null,"errorMessage":"width and height must be numbers between 0 and ${MAX_DIMENSION}","messagePattern":"width and height must be numbers between 0 and (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/studio/src/components/composition-drag-data.ts","lineNumber":194,"sourceCode":"\tcompositionFile,\n\tcompositionId,\n\twidth,\n\theight,\n\tdurationInFrames,\n}: MakeCompositionDragDataInput): SerializedCompositionDragData & {\n\treadonly data: CompositionDragData;\n} => {\n\tif ((width === null) !== (height === null)) {\n\t\tthrow new TypeError(\n\t\t\t'width and height must either both be numbers or both be null',\n\t\t);\n\t}\n\n\tif (\n\t\twidth !== null &&\n\t\t(!Number.isFinite(width) || width <= 0 || width > MAX_DIMENSION)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t`width and height must be numbers between 0 and ${MAX_DIMENSION}`,\n\t\t);\n\t}\n\n\tif (\n\t\theight !== null &&\n\t\t(!Number.isFinite(height) || height <= 0 || height > MAX_DIMENSION)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t`width and height must be numbers between 0 and ${MAX_DIMENSION}`,\n\t\t);\n\t}\n\n\tif (\n\t\tdurationInFrames !== null &&\n\t\t(!Number.isInteger(durationInFrames) ||\n\t\t\tdurationInFrames <= 0 ||\n\t\t\tdurationInFrames > MAX_DURATION_IN_FRAMES)","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/remotion-dev/remotion/blob/a6a7485a9aeb04219510fbe4874f8941486424df/packages/studio/src/components/composition-drag-data.ts#L176-L212","documentation":"makeCompositionDragData validates the width value before encoding it into drag MIME data. Width must be a finite number greater than 0 and at most MAX_DIMENSION; otherwise this TypeError is thrown. This prevents serializing corrupted or absurd dimensions into drag data consumed by other Studio targets.","triggerScenarios":"Calling makeCompositionDragData with width that is not finite (NaN/Infinity), <= 0, or larger than MAX_DIMENSION (while height is valid, so the pair check passed).","commonSituations":"Composition metadata not yet loaded (width undefined → NaN after coercion); a calculation bug producing 0 or negative sizes; unit confusion (percent vs px); oversized values from unbounded math.","solutions":["Sanitize width before calling: ensure Number.isFinite(width) && width > 0 && width <= MAX_DIMENSION","Fall back to null/null for both dimensions when width is not a valid finite number","Fix the source of the width value (e.g. composition.width should resolve after metadata loads; gate the call until then)","Log the offending value to identify the upstream calculation bug"],"exampleFix":"// before\nmakeCompositionDragData({..., width: comp.width * scale, height: comp.height * scale})\n// after\nconst w = comp.width * scale;\nconst h = comp.height * scale;\nconst ok = Number.isFinite(w) && w > 0 && w <= MAX_DIMENSION && Number.isFinite(h) && h > 0 && h <= MAX_DIMENSION;\nmakeCompositionDragData({..., width: ok ? w : null, height: ok ? h : null})","handlingStrategy":"validation","validationCode":"const validWidth = (w: number | null) =>\n  w !== null && Number.isFinite(w) && w > 0 && w <= MAX_DIMENSION ? w : null;","typeGuard":"const isValidDimension = (n: number | null): n is number =>\n  n !== null && Number.isFinite(n) && n > 0 && n <= MAX_DIMENSION;","tryCatchPattern":"try {\n  return makeCompositionDragData({..., width: rawWidth, height: rawHeight});\n} catch (err) {\n  if (err instanceof TypeError && err.message.includes('between 0 and')) {\n    return makeCompositionDragData({..., width: null, height: null});\n  }\n  throw err;\n}","preventionTips":["Sanitize dimensions with Number.isFinite before use","Gate drag-data creation until composition metadata is loaded","Clamp values to MAX_DIMENSION instead of trusting raw math","Check for NaN when coercing from strings or undefined"],"tags":["validation","typescript","drag-and-drop","studio"],"backgroundTag":"schema-validation-failed","analyzedSha":"a6a7485a9aeb04219510fbe4874f8941486424df","analyzedAt":"2026-09-02T16:25:19.997Z","contentChangedAt":"2026-09-02T16:25:19.997Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}