{"record":{"id":"e728d7aa8e8bd9b3","repo":"remotion-dev/remotion","slug":"name-must-be-max-but-got-json-string-e728d7","errorCode":null,"errorMessage":"\"${name}\" must be <= ${max}, but got ${JSON.stringify(value)}","messagePattern":"\"(.+?)\" must be <= (.+?), but got (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/effects/src/paper.ts","lineNumber":271,"sourceCode":"\tcolorFront: p.colorFront ?? DEFAULT_COLOR_FRONT,\n\tcolorBack: p.colorBack ?? DEFAULT_COLOR_BACK,\n\tcontrast: p.contrast ?? DEFAULT_CONTRAST,\n\troughness: p.roughness ?? DEFAULT_ROUGHNESS,\n\tfiber: p.fiber ?? DEFAULT_FIBER,\n\tfiberSize: p.fiberSize ?? DEFAULT_FIBER_SIZE,\n\tcrumples: p.crumples ?? DEFAULT_CRUMPLES,\n\tcrumpleSize: p.crumpleSize ?? DEFAULT_CRUMPLE_SIZE,\n\tfolds: p.folds ?? DEFAULT_FOLDS,\n\tfoldCount: p.foldCount ?? DEFAULT_FOLD_COUNT,\n\tdrops: p.drops ?? DEFAULT_DROPS,\n\tfade: p.fade ?? DEFAULT_FADE,\n\tseed: p.seed ?? DEFAULT_SEED,\n\tscale: p.scale ?? DEFAULT_SCALE,\n});\n\nconst validateAtMost = (value: number, max: number, name: string): void => {\n\tif (value > max) {\n\t\tthrow new TypeError(\n\t\t\t`\"${name}\" must be <= ${max}, but got ${JSON.stringify(value)}`,\n\t\t);\n\t}\n};\n\nconst validatePositiveUnitInterval = (value: number, name: string): void => {\n\tif (value <= 0) {\n\t\tthrow new TypeError(\n\t\t\t`\"${name}\" must be greater than 0, but got ${JSON.stringify(value)}`,\n\t\t);\n\t}\n\n\tvalidateAtMost(value, 1, name);\n};\n\nconst validatePaperParams = (params: PaperParams): void => {\n\tassertEffectParamsObject(params, 'Paper');\n\tassertOptionalFiniteNumber(params.amount, 'amount');","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/paper.ts#L253-L289","documentation":"Thrown by validateAtMost (packages/effects/src/paper.ts:271), reached from validatePaperParams for the upper-bound checks on fiberSize/crumpleSize (max 1 via validatePositiveUnitInterval), foldCount (max 15), seed (max 1000), and scale (max 4). It fires when the resolved value exceeds the documented maximum for that parameter.","triggerScenarios":"Calling paper({fiberSize: 1.5}), paper({crumpleSize: 2}), paper({foldCount: 20}), paper({seed: 5000}), or paper({scale: 5}); any resolved param above its declared max.","commonSituations":"Copying values from a design tool whose scale/seed ranges differ; animating a param with interpolate that overshoots its target; UI sliders configured with a wider range than the effect allows.","solutions":["Clamp the offending param to its max: fiberSize/crumpleSize ≤ 1, foldCount ≤ 15, seed ≤ 1000, scale ≤ 4.","When animating, use interpolate(..., {extrapolateLeft: 'clamp', extrapolateRight: 'clamp'}) so values never exceed bounds.","Validate deserialized params with the guard below before passing them to paper()."],"exampleFix":"// before\npaper({foldCount: 20, seed: 5000}); // throws\n\n// after\npaper({foldCount: 15, seed: 1000});","handlingStrategy":"validation","validationCode":"// Validate paper params against the documented maxima before calling paper()\nconst PAPER_MAX = {fiberSize: 1, crumpleSize: 1, foldCount: 15, seed: 1000, scale: 4};\n\nfunction withinPaperMax(p: Partial<Record<keyof typeof PAPER_MAX, number>>): boolean {\n  return (Object.keys(PAPER_MAX) as (keyof typeof PAPER_MAX)[]).every((k) => {\n    const v = p[k];\n    return v === undefined || v <= PAPER_MAX[k];\n  });\n}\n\nfunction clampPaperMax<T extends Partial<Record<keyof typeof PAPER_MAX, number>>>(p: T): T {\n  const out = {...p} as T;\n  (Object.keys(PAPER_MAX) as (keyof typeof PAPER_MAX)[]).forEach((k) => {\n    if (out[k] !== undefined) (out as Record<string, number>)[k] = Math.min(out[k] as number, PAPER_MAX[k]);\n  });\n  return out;\n}","typeGuard":"const isWithinPaperMax = (p: unknown): boolean => {\n  if (typeof p !== 'object' || p === null) return false;\n  const o = p as Record<string, unknown>;\n  return (['fiberSize','crumpleSize','foldCount','seed','scale'] as const).every((k) =>\n    o[k] === undefined || (typeof o[k] === 'number' && o[k] <= PAPER_MAX[k]));\n};","tryCatchPattern":"try {\n  paper(raw);\n} catch (err) {\n  if (err instanceof TypeError && /must be <=/.test(err.message)) {\n    paper(clampPaperMax(raw)); // clamp and retry\n  } else throw err;\n}","preventionTips":["Clamp animated params with interpolate(..., {extrapolateLeft: 'clamp', extrapolateRight: 'clamp'}).","Validate params from external sources before passing them to paper().","Keep UI slider bounds aligned with the documented maxima (fiberSize/crumpleSize ≤ 1, foldCount ≤ 15, seed ≤ 1000, scale ≤ 4)."],"tags":["validation","params","paper","effects","range"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}