{"record":{"id":"fc881c9a2f7922d3","repo":"mozilla/pdf.js","slug":"dictionary-key-must-be-a-name-object","errorCode":null,"errorMessage":"Dictionary key must be a name object","messagePattern":"Dictionary key must be a name object","errorType":"exception","errorClass":"FormatError","httpStatus":null,"severity":"error","filePath":"src/core/parser.js","lineNumber":545,"sourceCode":"      } else if (state === 2) {\n        break;\n      }\n    }\n  }\n\n  /**\n   * @param {CipherTransform | null} cipherTransform\n   * @returns {Streams}\n   */\n  makeInlineImage(cipherTransform) {\n    const lexer = this.lexer;\n    const stream = lexer.stream;\n\n    const dict = new Dict(this.xref);\n    let dictLength;\n    while (!isCmd(this.buf1, \"ID\") && this.buf1 !== EOF) {\n      if (!(this.buf1 instanceof Name)) {\n        throw new FormatError(\"Dictionary key must be a name object\");\n      }\n      const key = this.buf1.name;\n      this.shift();\n      if (this.buf1 === EOF) {\n        break;\n      }\n      dict.set(key, this.getObj(cipherTransform));\n    }\n    if (lexer.beginInlineImagePos !== -1) {\n      dictLength = stream.pos - lexer.beginInlineImagePos;\n    }\n\n    // Extract the name of the first (i.e. the current) image filter.\n    const filter = dict.get(\"F\", \"Filter\");\n    let filterName;\n    if (filter instanceof Name) {\n      filterName = filter.name;\n    } else if (Array.isArray(filter)) {","sourceCodeStart":527,"sourceCodeEnd":563,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/parser.js#L527-L563","documentation":"Thrown as a FormatError by Parser.makeInlineImage() while reading the key-value pairs of an inline image dictionary (the tokens between BI and ID). Inline image keys must be Name objects; if a non-Name token appears where a key is expected, the structure is malformed. Unlike the regular dict parser (which just warns and skips), the inline-image path is stricter and throws.","triggerScenarios":"makeInlineImage() loops while buf1 isn't 'ID' or EOF; each buf1 must be a Name. If a number, string, or Cmd appears as a key, the `instanceof Name` check fails and the FormatError fires. Happens in PDF content streams with malformed inline image syntax.","commonSituations":"A PDF page content stream with a broken BI/ID inline image — e.g. missing a value so the next token (a value) is read as a key, or an encoder that emitted non-name tokens. Often caused by content-stream corruption or a buggy PDF producer. Less common than the regular-dict variant because inline images are rare.","solutions":["Extract and inspect the page content stream around the BI operator to find the malformed key.","Re-export or rebuild the PDF with a reliable producer (Ghostscript, qpdf) to normalize the content stream.","If the image is non-essential, catch FormatError during page rendering to still show the rest of the page."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await page.render({ canvasContext }).promise;\n} catch (e) {\n  if (e.name === 'FormatError' && /name object/.test(e.message)) { /* malformed inline image */ }\n  else throw e;\n}","preventionTips":["Inspect the page content stream around BI/ID operators for malformed inline images.","Re-export suspect PDFs with Ghostscript/qpdf to normalize content streams.","Catch FormatError during render to still display the rest of the page."],"tags":["pdf","parser","inline-image","corrupt-data","structure"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}