{"record":{"id":"5d8ba3f67042f872","repo":"remotion-dev/remotion","slug":"invalid-lut-content-on-line-linenumber-keyword-must-appear","errorCode":null,"errorMessage":"Invalid LUT content on line ${lineNumber}: ${keyword} must appear before the color data","messagePattern":"Invalid LUT content on line (.+?): (.+?) must appear before the color data","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/effects/src/lut/parse-cube-lut.ts","lineNumber":83,"sourceCode":"\n\tfor (let index = 0; index < lines.length; index++) {\n\t\tconst lineNumber = index + 1;\n\t\tconst line = stripComment(lines[index]).trim();\n\t\tif (line.length === 0) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst [keyword, ...values] = line.split(/\\s+/);\n\n\t\tif (keyword === 'LUT_1D_SIZE') {\n\t\t\tthrow new TypeError(\n\t\t\t\t`Invalid LUT content on line ${lineNumber}: 1D LUTs are not supported`,\n\t\t\t);\n\t\t}\n\n\t\tif (HEADER_DIRECTIVES.has(keyword)) {\n\t\t\tif (dataStarted) {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t`Invalid LUT content on line ${lineNumber}: ${keyword} must appear before the color data`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (keyword === 'TITLE') {\n\t\t\t\tif (hasTitle) {\n\t\t\t\t\tthrow new TypeError(\n\t\t\t\t\t\t`Invalid LUT content on line ${lineNumber}: TITLE may only be declared once`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\thasTitle = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (keyword === 'LUT_3D_SIZE') {\n\t\t\t\tif (size !== null) {\n\t\t\t\t\tthrow new TypeError(","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/remotion-dev/remotion/blob/46a3a6bf13ca367376ff18bbb06dae2e87e0d068/packages/effects/src/lut/parse-cube-lut.ts#L65-L101","documentation":"parseCubeLut() parses .cube LUT files and requires all header directives (TITLE, LUT_3D_SIZE, DOMAIN_MIN, DOMAIN_MAX) to appear before any color data rows. If a header directive is encountered after the first color row, this TypeError is thrown because re-ordering or mixing headers into the data section is invalid per the .cube format.","triggerScenarios":"A .cube file passed to parseCubeLut() has a header line like TITLE or LUT_3D_SIZE or DOMAIN_MIN/MAX placed after at least one numeric color row, e.g. colors pasted before the size declaration or an appended header at the end of the file.","commonSituations":"Hand-edited LUT files, files concatenated in the wrong order, generators that emit data before headers, or tools that append metadata at the bottom of the file.","solutions":["Move all header directives (TITLE, LUT_3D_SIZE, DOMAIN_MIN, DOMAIN_MAX) to the top of the .cube file before any color rows","Regenerate or re-export the LUT from the original tool with correct header ordering","Check the line number in the message and inspect that line for a misplaced header keyword"],"exampleFix":"// before\n0 0 0\nLUT_3D_SIZE 2\n0 0 1\n// after\nLUT_3D_SIZE 2\n0 0 0\n0 0 1","handlingStrategy":"validation","validationCode":"const validateHeaderOrder = (content: string) => {\n  let dataStarted = false;\n  for (const line of content.split(/\\r?\\n/)) {\n    const trimmed = line.split('#')[0].trim();\n    if (!trimmed) continue;\n    if (/^\\d/.test(trimmed)) { dataStarted = true; continue; }\n    if (dataStarted && /^(TITLE|LUT_3D_SIZE|DOMAIN_MIN|DOMAIN_MAX)\\b/.test(trimmed)) {\n      throw new Error(`Header directive after data: ${trimmed}`);\n    }\n  }\n};","typeGuard":"null","tryCatchPattern":"try {\n  const lut = parseCubeLut(content);\n} catch (e) {\n  if (e instanceof TypeError && e.message.includes('must appear before the color data')) {\n    // re-order headers or surface a user-friendly LUT error\n  } else throw e;\n}","preventionTips":["Keep headers at the top of .cube files","Never append metadata to the end of a LUT file","Validate LUT files in CI before bundling them"],"tags":["validation","lut","file-format"],"backgroundTag":"invalid-argument-format","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"}