{"record":{"id":"ba37ab8e4371a628","repo":"remotion-dev/remotion","slug":"unknown-fit-fit","errorCode":null,"errorMessage":"Unknown fit: ${fit}","messagePattern":"Unknown fit: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/calculate-image-fit.ts","lineNumber":70,"sourceCode":"\t\t\t\tcanvasSize.height / imageSize.height,\n\t\t\t);\n\t\t\tconst centerX = (canvasSize.width - imageSize.width * ratio) / 2;\n\t\t\tconst centerY = (canvasSize.height - imageSize.height * ratio) / 2;\n\n\t\t\treturn [\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t\timageSize.width,\n\t\t\t\timageSize.height,\n\t\t\t\tcenterX,\n\t\t\t\tcenterY,\n\t\t\t\timageSize.width * ratio,\n\t\t\t\timageSize.height * ratio,\n\t\t\t];\n\t\t}\n\n\t\tdefault:\n\t\t\tthrow new Error('Unknown fit: ' + fit);\n\t}\n};\n","sourceCodeStart":52,"sourceCodeEnd":73,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/core/src/calculate-image-fit.ts#L52-L73","documentation":"calculateImageFit computes source/destination rectangles for drawing an image into a canvas for the 'contain', 'cover', and 'fill' strategies. The switch is intended to be exhaustive over the ImageFit union; the default branch throws to surface any value that escapes the union (typically via TypeScript escape hatches).","triggerScenarios":"Calling calculateImageFit('crop', ...) or calculateImageFit('scale-to-fill', ...). Usually reached by casting a string to ImageFit via 'as any'/'as ImageFit' or by passing user input that wasn't validated against the allowed set.","commonSituations":"Integrating a design tool's fit vocabulary (which has more options than Remotion supports); passing a runtime string from a config file; copy-pasting a fit value from another library.","solutions":["Use one of the supported values: 'contain', 'cover', or 'fill'.","If accepting user/config input, validate against an allowlist before calling.","Map unsupported fit values to the closest supported one at the boundary."],"exampleFix":"// before\ncalculateImageFit('scale-to-fill' as ImageFit, img, canvas)\n\n// after\ncalculateImageFit('fill', img, canvas)","handlingStrategy":"type-guard","validationCode":"const ALLOWED_FITS = new Set(['contain', 'cover', 'fill']);\nif (!ALLOWED_FITS.has(fit)) {\n  fit = 'contain'; // or throw your own error\n}","typeGuard":"const isImageFit = (v: unknown): v is 'contain' | 'cover' | 'fill' =>\n  v === 'contain' || v === 'cover' || v === 'fill';","tryCatchPattern":null,"preventionTips":["Validate external/config fit strings against the allowlist at the boundary.","Avoid `as ImageFit` casts on untrusted values.","Map unsupported fit vocabulary to the closest supported option."],"tags":["image","validation","typescript","exhaustive-switch"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}