{"record":{"id":"5d736e2ba44f56bf","repo":"mozilla/pdf.js","slug":"extgstate-should-be-a-dictionary","errorCode":null,"errorMessage":"ExtGState should be a dictionary.","messagePattern":"ExtGState should be a dictionary\\.","errorType":"exception","errorClass":"FormatError","httpStatus":null,"severity":"error","filePath":"src/core/evaluator.js","lineNumber":2182,"sourceCode":"              const localGStateObj = localGStateCache.getByName(name);\n              if (localGStateObj) {\n                if (localGStateObj.length > 0) {\n                  operatorList.addOp(OPS.setGState, [localGStateObj]);\n                }\n                args = null;\n                continue;\n              }\n            }\n\n            next(\n              new Promise(function (resolveGState, rejectGState) {\n                if (!isValidName) {\n                  throw new FormatError(\"GState must be referred to by name.\");\n                }\n\n                const extGState = resources.get(\"ExtGState\");\n                if (!(extGState instanceof Dict)) {\n                  throw new FormatError(\"ExtGState should be a dictionary.\");\n                }\n\n                const gState = extGState.get(name);\n                // TODO: Attempt to lookup cached GStates by reference as well,\n                //       if and only if there are PDF documents where doing so\n                //       would significantly improve performance.\n                if (!(gState instanceof Dict)) {\n                  throw new FormatError(\"GState should be a dictionary.\");\n                }\n\n                self\n                  .setGState({\n                    resources,\n                    gState,\n                    operatorList,\n                    cacheKey: name,\n                    task,\n                    stateManager,","sourceCodeStart":2164,"sourceCodeEnd":2200,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/evaluator.js#L2164-L2200","documentation":"FormatError thrown when the 'ExtGState' resource entry on the page/stream resources is not a PDF Dictionary. ExtGState must be a name->dictionary map; any other type makes graphics-state lookups impossible.","triggerScenarios":"resources.get('ExtGState') returns something that is not a Dict (null, a stream, a number), so 'extGState instanceof Dict' fails inside the setGState handler.","commonSituations":"Truncated or malformed resource dictionaries, broken indirect references to the ExtGState sub-dictionary, or generators placing the wrong object type.","solutions":["Enable ignoreErrors: true to skip the bad ExtGState lookup.","Repair the PDF so ExtGState is a proper dictionary.","Upgrade PDF.js."],"exampleFix":"// before\ngetDocument({ data }); // non-Dict ExtGState aborts render\n\n// after\ngetDocument({ data, ignoreErrors: true }); // bad ExtGState skipped","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await page.render({ canvasContext, viewport }).promise;\n} catch (e) {\n  if (/ExtGState should be a dictionary/.test(e.message)) {\n    await reloadWith({ ignoreErrors: true });\n  } else throw e;\n}","preventionTips":["Enable ignoreErrors for untrusted PDFs.","Repair resource dictionaries whose /ExtGState is not a Dict.","Upgrade PDF.js."],"tags":["pdf","gstate","graphics-state","malformed-pdf","rendering"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}