{"record":{"id":"ee6f6d266891325e","repo":"mozilla/pdf.js","slug":"gstate-should-be-a-dictionary","errorCode":null,"errorMessage":"GState should be a dictionary.","messagePattern":"GState should be a dictionary\\.","errorType":"exception","errorClass":"FormatError","httpStatus":null,"severity":"error","filePath":"src/core/evaluator.js","lineNumber":2190,"sourceCode":"            }\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,\n                    localGStateCache,\n                    localColorSpaceCache,\n                    seenRefs,\n                  })\n                  .then(resolveGState, rejectGState);\n              }).catch(function (reason) {\n                if (reason instanceof AbortException) {\n                  return;","sourceCodeStart":2172,"sourceCodeEnd":2208,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/evaluator.js#L2172-L2208","documentation":"FormatError thrown when a named ExtGState entry itself is not a Dictionary. ExtGState is a Dict, but the specific named value (e.g. 'gs1') resolves to a non-Dict, so the graphics state cannot be interpreted.","triggerScenarios":"extGState.get(name) returns something that is not a Dict (a primitive, stream, or null), so 'gState instanceof Dict' fails.","commonSituations":"Corrupt individual ExtGState entries, broken indirect refs to a single GState parameter dict, or partially-written PDFs.","solutions":["Enable ignoreErrors: true so the bad GState entry is skipped.","Repair the PDF so the named ExtGState entry is a valid dictionary.","Upgrade PDF.js."],"exampleFix":"// before\ngetDocument({ data }); // non-Dict GState entry aborts render\n\n// after\ngetDocument({ data, ignoreErrors: true }); // bad GState skipped","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await page.render({ canvasContext, viewport }).promise;\n} catch (e) {\n  if (/GState should be a dictionary/.test(e.message)) {\n    await reloadWith({ ignoreErrors: true });\n  } else throw e;\n}","preventionTips":["Enable ignoreErrors for untrusted PDFs.","Repair individual ExtGState entries that are not dictionaries.","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"}