{"record":{"id":"050e4b3a3d14ed66","repo":"mozilla/pdf.js","slug":"not-tracking-location-of-key","errorCode":null,"errorMessage":"Not tracking location of ${key}","messagePattern":"Not tracking location of (.+?)","errorType":"exception","errorClass":"FormatError","httpStatus":null,"severity":"error","filePath":"src/core/cff_parser.js","lineNumber":1461,"sourceCode":"    return key in this.offsets;\n  }\n\n  track(key, location) {\n    if (key in this.offsets) {\n      throw new FormatError(`Already tracking location of ${key}`);\n    }\n    this.offsets[key] = location;\n  }\n\n  offset(value) {\n    for (const key in this.offsets) {\n      this.offsets[key] += value;\n    }\n  }\n\n  setEntryLocation(key, values, output) {\n    if (!(key in this.offsets)) {\n      throw new FormatError(`Not tracking location of ${key}`);\n    }\n    const data = output.data;\n    const dataOffset = this.offsets[key];\n    const size = 5;\n    for (let i = 0, ii = values.length; i < ii; ++i) {\n      const offset0 = i * size + dataOffset;\n      const offset1 = offset0 + 1;\n      const offset2 = offset0 + 2;\n      const offset3 = offset0 + 3;\n      const offset4 = offset0 + 4;\n      // It's easy to screw up offsets so perform this sanity check.\n      if (\n        data[offset0] !== 0x1d ||\n        data[offset1] !== 0 ||\n        data[offset2] !== 0 ||\n        data[offset3] !== 0 ||\n        data[offset4] !== 0\n      ) {","sourceCodeStart":1443,"sourceCodeEnd":1479,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/cff_parser.js#L1443-L1479","documentation":"Thrown by CFFOffsetTracker.setEntryLocation when called for a key that was never registered via track(). setEntryLocation writes the final offset value into a placeholder slot that track() was supposed to reserve; calling it without a prior track means there is no slot to fill.","triggerScenarios":"The CFF compiler calls setEntryLocation(key, values, output) for a key not in the tracker's offsets map. This is an internal invariant violation — setEntryLocation should only be called for offset names previously passed to track().","commonSituations":"A pdf.js internal bug where setEntryLocation references a name that compileDict never tracked; a fork that calls setEntryLocation directly; mismatched key names between track and setEntryLocation code paths after a refactor.","solutions":["Verify the key passed to setEntryLocation was previously tracked via track() (or isTracking returns true).","Report to pdf.js with the offending font — this indicates an internal compiler bug.","Audit track/setEntryLocation call pairs to ensure matching key names."],"exampleFix":"// before\ntracker.setEntryLocation('Private', vals, output); // throws if never tracked\n\n// after\nif (tracker.isTracking('Private')) {\n  tracker.setEntryLocation('Private', vals, output);\n}","handlingStrategy":"validation","validationCode":"// Only call setEntryLocation for keys previously tracked.\nfunction safeSetEntryLocation(tracker, key, values, output) {\n  if (!tracker.isTracking(key)) {\n    throw new Error(`Refusing setEntryLocation: '${key}' not tracked`);\n  }\n  tracker.setEntryLocation(key, values, output);\n}","typeGuard":"function isTracked(tracker, key) {\n  return tracker.isTracking(key);\n}","tryCatchPattern":"try {\n  tracker.setEntryLocation(key, values, output);\n} catch (e) {\n  // Key was never tracked; internal compiler state bug.\n  throw new Error(`setEntryLocation for untracked key '${key}'`);\n}","preventionTips":["Ensure every setEntryLocation key was previously passed to track().","Keep track/setEntryLocation key names in sync across refactors.","Report unexpected occurrences to pdf.js with the offending font."],"tags":["font","cff","cff-compiler","offset-tracker","internal-api","invariant"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}