{"record":{"id":"bdcfded6c093c8c6","repo":"remotion-dev/remotion","slug":"expected-data-length-3-lut-colors-got-offset-3","errorCode":null,"errorMessage":"Expected ${data.length / 3} LUT colors, got ${offset / 3}.","messagePattern":"Expected (.+?) LUT colors, got (.+?)\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/studio/src/helpers/cube-lut.ts","lineNumber":130,"sourceCode":"\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\n\tif (type === null || data === null) {\n\t\tthrow new Error('Expected LUT_1D_SIZE or LUT_3D_SIZE.');\n\t}\n\n\tif (offset !== data.length) {\n\t\tthrow new Error(\n\t\t\t`Expected ${data.length / 3} LUT colors, got ${offset / 3}.`,\n\t\t);\n\t}\n\n\tif (domainMin.some((min, channel) => min >= domainMax[channel])) {\n\t\tthrow new Error(\n\t\t\t'DOMAIN_MAX must be greater than DOMAIN_MIN in every channel.',\n\t\t);\n\t}\n\n\tif (\n\t\tdomainMin.some((min, channel) => !Number.isFinite(domainMax[channel] - min))\n\t) {\n\t\tthrow new Error('LUT input ranges must be finite.');\n\t}\n\n\tif (\n\t\t(headers.has('LUT_1D_INPUT_RANGE') || headers.has('LUT_3D_INPUT_RANGE')) &&","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/remotion-dev/remotion/blob/46a3a6bf13ca367376ff18bbb06dae2e87e0d068/packages/studio/src/helpers/cube-lut.ts#L112-L148","documentation":"The number of color rows in a .cube file must exactly match the declared size: size rows for 1D LUTs, size^3 for 3D LUTs. After parsing, if the number of collected colors (offset/3) differs from data.length/3, this error is thrown reporting both counts. Unlike the 'got more' variant this fires when the table is incomplete — too few color lines.","triggerScenarios":"parseCubeLut(text) where declared LUT_3D_SIZE is 33 but only e.g. 30000 color lines follow (truncated download), or a 1D LUT declaring 32 entries but containing fewer; also a wrong size value (declaring 33 for a 32-entry table).","commonSituations":"Interrupted downloads/uploads truncating the tail of the file; text editors or copy-paste dropping the last lines; size header incremented without regenerating the table.","solutions":["Re-export or re-download the LUT file — truncation is the usual cause.","Adjust the size header down to match the actual row count if the table itself is intact (count data lines: 1D -> n, 3D -> cube root of n).","Compare the reported 'Expected X LUT colors, got Y' counts to determine whether the header or the data is wrong.","Validate the file length beforehand: count non-header lines and check against size^3."],"exampleFix":"// before: 32768 rows but header says 33^3=35937\nLUT_3D_SIZE 33\n// after (table has 32^3=32768 rows)\nLUT_3D_SIZE 32","handlingStrategy":"validation","validationCode":"const size = Number(/LUT_3D_SIZE\\s+(\\d+)/.exec(text)?.[1] ?? NaN);\nconst rows = text.split(/\\r?\\n/).filter((l) => {\n  const p = l.trim().split(/\\s+/);\n  return p.length === 3 && p.every((x) => Number.isFinite(Number(x)));\n}).length;\nif (Number.isFinite(size) && rows !== size ** 3) {\n  throw new Error(`Expected ${size ** 3} colors, file has ${rows}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const lut = parseCubeLut(text);\n} catch (e) {\n  const m = /Expected (\\d+) LUT colors, got (\\d+)/.exec((e as Error).message);\n  if (m) console.error(`Table truncated: have ${m[2]} of ${m[1]} colors`);\n}","preventionTips":["Verify downloads complete (compare file size/checksum) before parsing","Re-export truncated LUTs from the source tool","Match the size header to the actual cube root of the data row count"],"tags":["parsing","lut","validation"],"backgroundTag":"value-out-of-range","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"}