mozilla/pdf.js · error · FormatError
Invalid dictionary name ${name}"
Error message
Invalid dictionary name ${name}" What it means
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.
Source
Thrown at src/core/cff_parser.js:1280
}
this.values[key] = value;
return true;
}
setByName(name, value) {
if (!(name in this.nameToKeyMap)) {
throw new FormatError(`Invalid dictionary name "${name}"`);
}
this.values[this.nameToKeyMap[name]] = value;
}
hasName(name) {
return this.nameToKeyMap[name] in this.values;
}
getByName(name) {
if (!(name in this.nameToKeyMap)) {
throw new FormatError(`Invalid dictionary name ${name}"`);
}
const key = this.nameToKeyMap[name];
if (!(key in this.values)) {
return this.defaults[key];
}
return this.values[key];
}
removeByName(name) {
delete this.values[this.nameToKeyMap[name]];
}
static createTables(layout) {
const tables = {
keyToNameMap: {},
nameToKeyMap: {},
defaults: {},
types: {},View on GitHub (pinned to 5903d58d58)
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).
Example fix
// before
const v = dict.getByName('SomeOp'); // throws if unregistered
// after
if (dict.hasName('SomeOp')) {
const v = dict.getByName('SomeOp');
} else {
// fall back to a default or skip
} Defensive patterns
Strategy: validation
Validate before calling
// Use hasName before getByName to avoid the throw.
function safeGetByName(dict, name) {
if (!dict.hasName(name)) {
return undefined; // or a caller-supplied default
}
return dict.getByName(name);
} Type guard
function isValidCFFDictName(dict, name) {
return typeof name === 'string' && name in dict.nameToKeyMap;
} Try / catch
try {
v = dict.getByName(name);
} catch (e) {
// Unregistered name; internal API misuse.
v = undefined;
} Prevention
- 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).
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Invalid dictionary name "${name}"
- Already tracking location of ${key}
- Not tracking location of ${key}
- writing to an offset that is not empty
- There must be a private dictionary.
AI-assisted analysis of mozilla/pdf.js@5903d58d58 (2026-08-13).
Data as JSON: /api/errors/6d758e460474c5ad.
Report an issue: GitHub.