{"record":{"id":"6d758e460474c5ad","repo":"mozilla/pdf.js","slug":"invalid-dictionary-name-name-6d758e","errorCode":null,"errorMessage":"Invalid dictionary name ${name}\"","messagePattern":"Invalid dictionary name (.+?)\"","errorType":"exception","errorClass":"FormatError","httpStatus":null,"severity":"error","filePath":"src/core/cff_parser.js","lineNumber":1280,"sourceCode":"    }\n    this.values[key] = value;\n    return true;\n  }\n\n  setByName(name, value) {\n    if (!(name in this.nameToKeyMap)) {\n      throw new FormatError(`Invalid dictionary name \"${name}\"`);\n    }\n    this.values[this.nameToKeyMap[name]] = value;\n  }\n\n  hasName(name) {\n    return this.nameToKeyMap[name] in this.values;\n  }\n\n  getByName(name) {\n    if (!(name in this.nameToKeyMap)) {\n      throw new FormatError(`Invalid dictionary name ${name}\"`);\n    }\n    const key = this.nameToKeyMap[name];\n    if (!(key in this.values)) {\n      return this.defaults[key];\n    }\n    return this.values[key];\n  }\n\n  removeByName(name) {\n    delete this.values[this.nameToKeyMap[name]];\n  }\n\n  static createTables(layout) {\n    const tables = {\n      keyToNameMap: {},\n      nameToKeyMap: {},\n      defaults: {},\n      types: {},","sourceCodeStart":1262,"sourceCodeEnd":1298,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/cff_parser.js#L1262-L1298","documentation":"Thrown by CFFDict.getByName when called with a name absent from the dictionary's nameToKeyMap. Note the message string has a quoting typo (`Invalid dictionary name ${name}\"` is missing its opening quote and untemplatized). Like setByName, this is an internal API contract violation, not reachable from ordinary PDF input.","triggerScenarios":"Internal code calls `dict.getByName('UnknownName')` for a name not in the dict's layout table. Indicates a programming error in code reading CFF dictionary values.","commonSituations":"A pdf.js patch referencing an operator name that was never registered in the layout table; typos in name strings passed to getByName; stale code after a layout table rename.","solutions":["Use only names that exist in the relevant CFF*DictLayout table.","Prefer hasName() before getByName() if the name may be absent.","Fix the quoting typo in the message if you are patching pdf.js (missing opening quote and missing template literal)."],"exampleFix":"// before\nconst v = dict.getByName('SomeOp'); // throws if unregistered\n\n// after\nif (dict.hasName('SomeOp')) {\n  const v = dict.getByName('SomeOp');\n} else {\n  // fall back to a default or skip\n}","handlingStrategy":"validation","validationCode":"// Use hasName before getByName to avoid the throw.\nfunction safeGetByName(dict, name) {\n  if (!dict.hasName(name)) {\n    return undefined; // or a caller-supplied default\n  }\n  return dict.getByName(name);\n}","typeGuard":"function isValidCFFDictName(dict, name) {\n  return typeof name === 'string' && name in dict.nameToKeyMap;\n}","tryCatchPattern":"try {\n  v = dict.getByName(name);\n} catch (e) {\n  // Unregistered name; internal API misuse.\n  v = undefined;\n}","preventionTips":["Always call hasName() before getByName() for optional operators.","Keep getByName/setByName name arguments consistent with the layout table.","If patching pdf.js, also fix the message quoting typo (missing opening quote)."],"tags":["font","cff","cff-dict","internal-api","invariant"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}