{"record":{"id":"297b09eb5edf331f","repo":"mozilla/pdf.js","slug":"indexedcs-unrecognized-lookup-table-lookup","errorCode":null,"errorMessage":"IndexedCS - unrecognized lookup table: ${lookup}","messagePattern":"IndexedCS - unrecognized lookup table: (.+?)","errorType":"exception","errorClass":"FormatError","httpStatus":null,"severity":"error","filePath":"src/core/colorspace.js","lineNumber":495,"sourceCode":"class IndexedCS extends ColorSpace {\n  #rgbLookup;\n\n  constructor(base, highVal, lookup) {\n    super(\"Indexed\", 1);\n    this.highVal = highVal;\n\n    const count = highVal + 1;\n    const length = base.numComps * count;\n    const palette = new Uint8Array(length);\n\n    if (lookup instanceof BaseStream) {\n      palette.set(lookup.getBytes(length));\n    } else if (typeof lookup === \"string\") {\n      for (let i = 0; i < length; ++i) {\n        palette[i] = lookup.charCodeAt(i);\n      }\n    } else {\n      throw new FormatError(`IndexedCS - unrecognized lookup table: ${lookup}`);\n    }\n\n    this.#rgbLookup = new Uint8ClampedArray(count * 3);\n    base.getRgbBuffer(\n      palette,\n      0,\n      count,\n      this.#rgbLookup,\n      0,\n      /* bits = */ 8,\n      /* alpha01 = */ 0\n    );\n  }\n\n  getRgbItem(src, srcOffset, dest, destOffset) {\n    if (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")) {\n      assert(\n        dest instanceof Uint8ClampedArray,","sourceCodeStart":477,"sourceCodeEnd":513,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/colorspace.js#L477-L513","documentation":"Thrown while constructing an Indexed color space when the lookup table (the palette argument) is neither a BaseStream nor a JS string. pdf.js only accepts stream-backed or string palettes for /Indexed color spaces; any other type (number, Name, array, null) is rejected.","triggerScenarios":"A PDF /Indexed colorspace whose lookup table is a number, Name, array, or null/undefined - typically from a malformed dictionary or an unresolved indirect object reference that yielded a non-stream scalar.","commonSituations":"Corrupt PDF; broken cross-reference table causing object resolution to return a wrong type; a custom PDF generator emitting the wrong object type for the palette.","solutions":["Repair or regenerate the PDF.","Update pdf.js; newer versions resolve more indirect-reference cases correctly.","Catch FormatError and let pdf.js fall back to a default color space for the image."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"import { BaseStream } from './base_stream.js';\nfunction isValidLookup(lookup) {\n  return lookup instanceof BaseStream || typeof lookup === 'string';\n}","tryCatchPattern":"try {\n  cs = ColorSpace.parse(res, xref, cs, pdfFunctionFactory);\n} catch (e) {\n  if (e instanceof FormatError && /unrecognized lookup table/.test(e.message)) {\n    console.warn('Bad Indexed lookup table, falling back to default colorspace', e);\n    cs = null;\n  } else throw e;\n}","preventionTips":["Validate untrusted PDFs before rendering.","Keep pdf.js updated for better indirect-reference resolution.","When generating /Indexed color spaces, emit the palette as a stream or hex string.","Treat colorspace parse failures as non-fatal where possible."],"tags":["colorspace","indexed","parsing","pdf"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}