{"record":{"id":"b1cd70011a1ff9e3","repo":"mozilla/pdf.js","slug":"unknown-data-type-of-type","errorCode":null,"errorMessage":"Unknown data type of ${type}","messagePattern":"Unknown data type of (.+?)","errorType":"exception","errorClass":"FormatError","httpStatus":null,"severity":"error","filePath":"src/core/cff_parser.js","lineNumber":1834,"sourceCode":"            // deal with figuring out the length of the offset when it gets\n            // replaced later on by the compiler.\n            const name = dict.keyToNameMap[key];\n            // Some offsets have the offset and the length, so just record the\n            // position of the first one.\n            if (!offsetTracker.isTracking(name)) {\n              offsetTracker.track(name, out.length);\n            }\n            out.push(0x1d, 0, 0, 0, 0);\n            break;\n          case \"array\":\n          case \"delta\":\n            out.push(...this.encodeNumber(value));\n            for (let k = 1, kk = values.length; k < kk; ++k) {\n              out.push(...this.encodeNumber(values[k]));\n            }\n            break;\n          default:\n            throw new FormatError(`Unknown data type of ${type}`);\n        }\n      }\n      out.push(...dict.opcodes[key]);\n    }\n    return out;\n  }\n\n  compileStringIndex(strings) {\n    const stringIndex = new CFFIndex();\n    for (const string of strings) {\n      stringIndex.add(stringToBytes(string));\n    }\n    return this.compileIndex(stringIndex);\n  }\n\n  compileCharStrings(charStrings) {\n    const charStringsIndex = new CFFIndex();\n    for (let i = 0; i < charStrings.count; i++) {","sourceCodeStart":1816,"sourceCodeEnd":1852,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/cff_parser.js#L1816-L1852","documentation":"Thrown by CFFCompiler.compileDict when a dictionary entry's declared type is none of num, sid, offset, array, or delta. The type comes from the dictionary layout table, so an unknown type means the layout table is corrupt or was extended without updating the compile switch.","triggerScenarios":"Internal: compileDict reads `type = dict.types[key]` for a value present in dict.values, and the type string is not handled by the switch default branch. Indicates a layout-table/switch mismatch in pdf.js internals.","commonSituations":"A pdf.js patch that adds a new operator type to a layout table but forgets to add a case in compileDict; a fork that introduces custom types; corruption of the in-memory types map.","solutions":["Add a matching case in the compileDict switch for any new type you introduce in a layout table.","Audit layout-table type strings against the compileDict switch cases.","Report to pdf.js if triggered with unmodified code — it indicates an internal bug."],"exampleFix":"// before\n// layout table: [opcode, 'Op', 'boolnum', default]  // 'boolnum' unhandled -> throws\n\n// after\n// layout table: [opcode, 'Op', 'num', default]  // use a handled type\n// or add a case in compileDict:\n//   case 'boolnum':\n//     out.push(...this.encodeNumber(value ? 1 : 0));\n//     break;","handlingStrategy":"validation","validationCode":"// Ensure layout-table types are all handled by compileDict.\nconst HANDLED_TYPES = new Set(['num', 'sid', 'offset', 'array', 'delta']);\nfunction validateLayoutTypes(layout) {\n  const unknown = [];\n  for (const entry of layout) {\n    const types = Array.isArray(entry[2]) ? entry[2] : [entry[2]];\n    for (const t of types) {\n      if (!HANDLED_TYPES.has(t)) unknown.push({ name: entry[1], type: t });\n    }\n  }\n  if (unknown.length) throw new Error('Unhandled layout types: ' + JSON.stringify(unknown));\n}","typeGuard":"function isHandledCFFType(type) {\n  return ['num', 'sid', 'offset', 'array', 'delta'].includes(type);\n}","tryCatchPattern":"try {\n  this.compileDict(dict, tracker);\n} catch (e) {\n  // Unknown data type in layout table; internal mismatch.\n  throw new Error('compileDict hit an unhandled layout type');\n}","preventionTips":["Keep the compileDict switch cases in sync with all layout-table type strings.","Add a compile-time/test-time check that validates layout types against the switch.","Treat this error as a code bug introduced by a layout-table change."],"tags":["font","cff","cff-compiler","internal-api","invariant","layout-table"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}