{"record":{"id":"f7a47400016c7dc7","repo":"remotion-dev/remotion","slug":"expected-lut-1d-size-or-lut-3d-size-before-color-data","errorCode":null,"errorMessage":"Expected LUT_1D_SIZE or LUT_3D_SIZE before color data.","messagePattern":"Expected LUT_1D_SIZE or LUT_3D_SIZE before color data\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/studio/src/helpers/cube-lut.ts","lineNumber":106,"sourceCode":"\t\t\t\t!numbers.every(Number.isFinite) ||\n\t\t\t\tnumbers[0] >= numbers[1]\n\t\t\t) {\n\t\t\t\tthrow new Error(`${keyword} must contain an increasing input range.`);\n\t\t\t}\n\n\t\t\tdomainMin = [numbers[0], numbers[0], numbers[0]];\n\t\t\tdomainMax = [numbers[1], numbers[1], numbers[1]];\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (isHeader) {\n\t\t\tthrow new Error(\n\t\t\t\t`Unsupported LUT header \"${keyword}\" on line ${index + 1}.`,\n\t\t\t);\n\t\t}\n\n\t\tif (data === null) {\n\t\t\tthrow new Error('Expected LUT_1D_SIZE or LUT_3D_SIZE before color data.');\n\t\t}\n\n\t\tconst color = [Number(keyword), ...numbers];\n\t\tif (\n\t\t\tcolor.length !== 3 ||\n\t\t\t!color.every((value) => Number.isFinite(Math.fround(value)))\n\t\t) {\n\t\t\tthrow new Error(`Invalid LUT color on line ${index + 1}.`);\n\t\t}\n\n\t\tif (offset + 3 > data.length) {\n\t\t\tthrow new Error(`Expected ${data.length / 3} LUT colors, got more.`);\n\t\t}\n\n\t\tdata.set(color, offset);\n\t\toffset += 3;\n\t}\n","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/remotion-dev/remotion/blob/46a3a6bf13ca367376ff18bbb06dae2e87e0d068/packages/studio/src/helpers/cube-lut.ts#L88-L124","documentation":"A .cube file must declare its table size (LUT_1D_SIZE or LUT_3D_SIZE) before any color data lines appear, because the size determines how large the Float32Array backing the table is allocated. parseCubeLut throws this when it encounters a line that is not a recognized header and does not look like one, but no size header has been seen yet, i.e. color data would arrive with no buffer to fill.","triggerScenarios":"parseCubeLut(text) where the first non-comment, non-empty lines are numeric color triples and the LUT_*_SIZE line is missing, appears after the data, or was dropped by a preprocessing step that stripped headers.","commonSituations":"Truncated or hand-assembled .cube exports containing only the color table; scripts that concatenate data sections of two files; files where the size header was commented out.","solutions":["Add the required size header at the top of the file, e.g. 'LUT_3D_SIZE 33' (or 'LUT_1D_SIZE 32' for 1D LUTs).","Ensure the size header precedes all color data lines in the file.","Re-export the LUT from the original tool; the export is likely corrupted.","In code, pre-validate that the text contains a LUT_1D_SIZE or LUT_3D_SIZE line before the first numeric line."],"exampleFix":"// before\n0 0 0\n0.03125 0 0\n// after\nLUT_3D_SIZE 33\n0 0 0\n0.03125 0 0","handlingStrategy":"validation","validationCode":"if (!/(^|\\n)\\s*LUT_(1D|3D)_SIZE\\b/.test(text)) {\n  throw new Error('LUT file is missing LUT_1D_SIZE or LUT_3D_SIZE header');\n}","typeGuard":"const hasSizeHeader = (text: string): boolean =>\n  /(^|\\n)\\s*LUT_(1D|3D)_SIZE\\b/.test(text);","tryCatchPattern":"try {\n  const lut = parseCubeLut(text);\n} catch (e) {\n  alert(`Invalid .cube file: ${(e as Error).message}`);\n}","preventionTips":["Always place LUT_*_SIZE as the first meaningful line","Never strip or reorder headers when post-processing .cube files","Confirm the source file is genuinely .cube format, not .3dl/.csp"],"tags":["parsing","lut","validation"],"backgroundTag":"missing-required-argument","analyzedSha":"46a3a6bf13ca367376ff18bbb06dae2e87e0d068","analyzedAt":"2026-09-18T00:12:20.256Z","contentChangedAt":"2026-09-18T00:12:20.256Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}