{"record":{"id":"bd92317282521af4","repo":"remotion-dev/remotion","slug":"durationinframes-must-be-an-integer-between-1-and","errorCode":null,"errorMessage":"durationInFrames must be an integer between 1 and ${MAX_DURATION_IN_FRAMES}","messagePattern":"durationInFrames must be an integer between 1 and (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/studio/src/components/composition-drag-data.ts","lineNumber":214,"sourceCode":"\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)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t`durationInFrames must be an integer between 1 and ${MAX_DURATION_IN_FRAMES}`,\n\t\t);\n\t}\n\n\tconst data: CompositionDragData = {\n\t\ttype: 'remotion-composition',\n\t\tversion: 1,\n\t\tcompositionFile,\n\t\tcompositionId,\n\t};\n\tconst segments = [\n\t\tREMOTION_DRAG_MIME_TYPE,\n\t\t`v=${DRAG_MIME_VERSION}`,\n\t\t'type=composition',\n\t];\n\tif (width !== null && height !== null) {\n\t\tsegments.push(`width=${width}`, `height=${height}`);\n\t}","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/remotion-dev/remotion/blob/a6a7485a9aeb04219510fbe4874f8941486424df/packages/studio/src/components/composition-drag-data.ts#L196-L232","documentation":"makeCompositionDragData validates durationInFrames before encoding it. When provided, it must be an integer >= 1 and <= MAX_DURATION_IN_FRAMES; non-integers, zero, negatives, and excessive values throw this TypeError. Duration is optional (null allowed) but must be exact when present because it is serialized as an integer in the drag MIME string.","triggerScenarios":"Calling makeCompositionDragData with durationInFrames that is fractional (e.g. from frame math with interpolation), <= 0, or exceeding MAX_DURATION_IN_FRAMES.","commonSituations":"durationInFrames computed via division/averaging producing 2.5; a composition with durationInFrames still undefined coerced to NaN; copy/paste of durations from other units (seconds vs frames); huge values from unbounded calculations.","solutions":["Ensure the value is an integer: Math.round(comp.durationInFrames) before passing","If duration is unknown, pass null instead of a guessed number","Clamp to [1, MAX_DURATION_IN_FRAMES] before calling","Fix the source: read durationInFrames directly from the resolved composition rather than deriving it"],"exampleFix":"// before\nmakeCompositionDragData({..., durationInFrames: comp.durationInFrames / fps * fps})\n// after\nconst d = comp.durationInFrames;\nconst valid = Number.isInteger(d) && d > 0 && d <= MAX_DURATION_IN_FRAMES;\nmakeCompositionDragData({..., durationInFrames: valid ? d : null})","handlingStrategy":"validation","validationCode":"const d = comp.durationInFrames;\nconst validDuration = Number.isInteger(d) && d > 0 && d <= MAX_DURATION_IN_FRAMES ? d : null;","typeGuard":"const isValidDuration = (n: number | null): n is number =>\n  n !== null && Number.isInteger(n) && n > 0 && n <= MAX_DURATION_IN_FRAMES;","tryCatchPattern":"try {\n  return makeCompositionDragData({..., durationInFrames: rawDuration});\n} catch (err) {\n  if (err instanceof TypeError && err.message.includes('durationInFrames')) {\n    return makeCompositionDragData({..., durationInFrames: null});\n  }\n  throw err;\n}","preventionTips":["Math.round any duration computed through division or interpolation","Pass null when the duration is unknown rather than guessing","Keep durations in frames, not seconds, to avoid unit drift","Clamp to [1, MAX_DURATION_IN_FRAMES] before calling"],"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"}