{"record":{"id":"2972f4bacfa51ebf","repo":"heygen-com/hyperframes","slug":"invalid-number-value","errorCode":null,"errorMessage":"Invalid number \"${value}\"","messagePattern":"Invalid number \"(.+?)\"","errorType":"validation","errorClass":"CubeLutParseError","httpStatus":null,"severity":"error","filePath":"packages/core/src/colorLuts.ts","lineNumber":48,"sourceCode":"\nconst DEFAULT_DOMAIN_MIN: CubeLutVec3 = [0, 0, 0];\nconst DEFAULT_DOMAIN_MAX: CubeLutVec3 = [1, 1, 1];\nexport const DEFAULT_MAX_CUBE_LUT_SIZE = 64;\n\nfunction stripComment(line: string): string {\n  let inQuote = false;\n  for (let i = 0; i < line.length; i++) {\n    const char = line[i];\n    if (char === '\"') inQuote = !inQuote;\n    if (char === \"#\" && !inQuote) return line.slice(0, i);\n  }\n  return line;\n}\n\nfunction parseFiniteNumber(value: string, lineNumber: number): number {\n  const parsed = Number(value);\n  if (!Number.isFinite(parsed)) {\n    throw new CubeLutParseError(`Invalid number \"${value}\"`, lineNumber);\n  }\n  return parsed;\n}\n\nfunction parseVec3(parts: string[], keyword: string, lineNumber: number): CubeLutVec3 {\n  if (parts.length !== 3) {\n    throw new CubeLutParseError(`${keyword} expects three numbers`, lineNumber);\n  }\n  return [\n    parseFiniteNumber(parts[0]!, lineNumber),\n    parseFiniteNumber(parts[1]!, lineNumber),\n    parseFiniteNumber(parts[2]!, lineNumber),\n  ];\n}\n\nfunction parseSize(value: string | undefined, keyword: string, lineNumber: number): number {\n  if (!value) throw new CubeLutParseError(`${keyword} expects a size`, lineNumber);\n  const parsed = Number(value);","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/heygen-com/hyperframes/blob/c2996c8626135db5253519359d8a063d3bafad8d/packages/core/src/colorLuts.ts#L30-L66","documentation":"parseFiniteNumber converts a .cube token to a JS number and rejects anything that is not finite (NaN, Infinity, or non-numeric text). It is the shared numeric coercion for DOMAIN_MIN/MAX, LUT_3D_INPUT_RANGE, and data-row channels. The error echoes the offending token so you can locate it.","triggerScenarios":"A .cube file containing a non-numeric token where a number is expected: e.g. a data row like '0.1 abc 0.3', a DOMAIN_MIN line with text, or a token that Number() parses to NaN.","commonSituations":"Corrupted or truncated download; locale-formatted file using a comma as decimal separator; stray BOM or non-breaking space inside a value; a comment marker inside a quoted title leaking into numeric context.","solutions":["Open the file at the reported line and inspect the offending token quoted in the message.","If the file uses comma decimals, re-export with a period as the decimal separator.","Strip non-numeric bytes / fix encoding before calling parseCubeLut.","Re-download or re-export the LUT from the source tool."],"exampleFix":"// before — file contains: 0.10 0,5 0.30  (comma decimal)\nparseCubeLut(fileText);\n\n// after — normalize decimal separators\nparseCubeLut(fileText.replace(/,(?=\\d)/g, '.'));","handlingStrategy":"try-catch","validationCode":"function tryFinite(value: string): number | null {\n  const n = Number(value);\n  return Number.isFinite(n) ? n : null;\n}\n\n// pre-scan tokens before parseCubeLut\nfor (const tok of allNumericTokens(fileText)) {\n  if (tryFinite(tok) === null) throw new Error(`Bad numeric token: ${tok}`);\n}","typeGuard":null,"tryCatchPattern":"import { CubeLutParseError } from '@hyperframes/core';\n\ntry {\n  const lut = parseCubeLut(fileText);\n} catch (err) {\n  if (err instanceof CubeLutParseError) {\n    console.error(`LUT parse failed at line ${err.lineNumber}: ${err.message}`);\n    // surface to user, fall back to an identity LUT, or re-export\n  }\n  throw err;\n}","preventionTips":["Treat .cube files as untrusted input — wrap parseCubeLut in try/catch on CubeLutParseError.","Re-export LUTs from the source tool rather than hand-editing numeric data.","Normalize decimal separators (comma -> period) before parsing locale-formatted files."],"tags":["lut","cube","parsing","numeric"],"backgroundTag":null,"analyzedSha":"c2996c8626135db5253519359d8a063d3bafad8d","analyzedAt":"2026-08-12T22:18:56.877Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}