{"record":{"id":"a1b817edcc4b525b","repo":"mozilla/pdf.js","slug":"whitepoint-missing-required-for-color-space-lab","errorCode":null,"errorMessage":"WhitePoint missing - required for color space Lab","messagePattern":"WhitePoint missing - required for color space Lab","errorType":"exception","errorClass":"FormatError","httpStatus":null,"severity":"error","filePath":"src/core/colorspace.js","lineNumber":1207,"sourceCode":"    }\n  }\n\n  getOutputLength(inputLength, alpha01) {\n    return ((inputLength * (3 + alpha01)) / 3) | 0;\n  }\n}\n\n/**\n * LabCS: Based on \"PDF Reference, Sixth Ed\", p.250\n *\n * The default color is `new Float32Array([0, 0, 0])`.\n */\nclass LabCS extends ColorSpace {\n  constructor(whitePoint, blackPoint, range) {\n    super(\"Lab\", 3);\n\n    if (!whitePoint) {\n      throw new FormatError(\n        \"WhitePoint missing - required for color space Lab\"\n      );\n    }\n    // Translate args to spec variables\n    [this.XW, this.YW, this.ZW] = whitePoint;\n    [this.amin, this.amax, this.bmin, this.bmax] = range || [\n      -100, 100, -100, 100,\n    ];\n\n    // These are here just for completeness - the spec doesn't offer any\n    // formulas that use BlackPoint in Lab\n    [this.XB, this.YB, this.ZB] = blackPoint || [0, 0, 0];\n\n    // Validate vars as per spec\n    if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {\n      throw new FormatError(\n        \"Invalid WhitePoint components, no fallback available\"\n      );","sourceCodeStart":1189,"sourceCodeEnd":1225,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/colorspace.js#L1189-L1225","documentation":"Thrown by the LabCS constructor when the /WhitePoint array is missing or falsy for a /Lab color space. WhitePoint is mandatory for Lab calibration per the PDF spec; pdf.js refuses to default it because Lab color is meaningless without a reference white.","triggerScenarios":"Constructing LabCS with whitePoint = null/undefined/[], or parsing a PDF /Lab dictionary that lacks /WhitePoint.","commonSituations":"Corrupt PDF with an incomplete Lab dictionary; a faulty PDF generator that omitted the reference white.","solutions":["Repair the PDF to include a valid /WhitePoint array (Y normalized to 1).","Update pdf.js."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function hasWhitePoint(csDict) {\n  const wp = csDict.get('WhitePoint');\n  return Array.isArray(wp) && wp.length === 3;\n}","tryCatchPattern":"try {\n  cs = ColorSpace.parse(res, xref, cs, pdfFunctionFactory);\n} catch (e) {\n  if (e instanceof FormatError && /WhitePoint missing.*Lab/.test(e.message)) {\n    console.warn('Lab missing WhitePoint, falling back', e);\n    cs = null;\n  } else throw e;\n}","preventionTips":["When generating /Lab color spaces, always include /WhitePoint.","Validate untrusted PDFs before rendering.","Keep pdf.js updated.","Fall back to a default colorspace when Lab construction fails."],"tags":["colorspace","lab","cie","parsing","pdf"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}