{"record":{"id":"5b143c3485b9bff6","repo":"mozilla/pdf.js","slug":"ensure-that-the-kind-api-parameter-is-provide","errorCode":null,"errorMessage":"Ensure that the `${kind}` API parameter is provided.","messagePattern":"Ensure that the `(.+?)` API parameter is provided\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/display/binary_data_factory.js","lineNumber":49,"sourceCode":"      unreachable(\"Cannot initialize BaseBinaryDataFactory.\");\n    }\n    this.cMapUrl = cMapUrl;\n    this.standardFontDataUrl = standardFontDataUrl;\n    this.wasmUrl = wasmUrl;\n  }\n\n  async fetch({ kind, filename }) {\n    switch (kind) {\n      case \"cMapUrl\":\n      case \"standardFontDataUrl\":\n      case \"wasmUrl\":\n        break;\n      default:\n        unreachable(`Not implemented: ${kind}`);\n    }\n    const baseUrl = this[kind];\n    if (!baseUrl) {\n      throw new Error(`Ensure that the \\`${kind}\\` API parameter is provided.`);\n    }\n    const url = `${baseUrl}${filename}`;\n\n    return this._fetch(url, kind).catch(reason => {\n      throw new Error(`Unable to load ${this.#errorStr[kind]} data at: ${url}`);\n    });\n  }\n\n  /**\n   * @ignore\n   * @returns {Promise<Uint8Array>}\n   */\n  async _fetch(url, kind) {\n    unreachable(\"Abstract method `_fetch` called.\");\n  }\n}\n\nclass DOMBinaryDataFactory extends BaseBinaryDataFactory {","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/display/binary_data_factory.js#L31-L67","documentation":"Thrown by BaseBinaryDataFactory.fetch({ kind, filename }) when this[kind] is falsy, i.e., the corresponding configuration parameter was not supplied. The factory is used internally to load CMap binary files (cMapUrl), standard font metrics (standardFontDataUrl), and WASM decoders such as OpenJPEG (wasmUrl). Without a base URL there is no place to fetch the resource from.","triggerScenarios":"Loading a CJK PDF without configuring cMapUrl; a PDF using a non-embedded standard font without standardFontDataUrl; a JPEG2000 image when openjpeg WASM is required but wasmUrl is unset.","commonSituations":"Self-hosting pdfjs-dist and forgetting the /cmaps/ and /standard_fonts/ asset folders; bundle configs that tree-shake the wasmUrl; moving from the legacy build (which had bundled bcmaps) to the modular one.","solutions":["Install pdfjs-dist's cmaps and standard fonts assets and point cMapUrl / standardFontDataUrl at them (with trailing '/').","If you ship JPEG2000 support, set wasmUrl to the folder containing the openjpeg wasm.","Confirm the URLs resolve over HTTP (200) before relying on them."],"exampleFix":"// before\ngetDocument({ data });\n\n// after\ngetDocument({\n  data,\n  cMapUrl: 'https://cdn.example.com/cmaps/',\n  standardFontDataUrl: 'https://cdn.example.com/standard_fonts/',\n});","handlingStrategy":"validation","validationCode":"function validatePdfjsConfig(cfg) {\n  const needed = [];\n  if (cfg.useCMaps && !cfg.cMapUrl) needed.push('cMapUrl');\n  if (!cfg.standardFontDataUrl) needed.push('standardFontDataUrl');\n  if (needed.length) throw new Error('Missing pdfjs config: ' + needed.join(', '));\n}\nvalidatePdfjsConfig(config);","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Always configure cMapUrl when you may render CJK content.","Always configure standardFontDataUrl when fonts may be unembedded.","Document the asset folders your bundle must ship alongside pdfjs-dist."],"tags":["cmaps","fonts","wasm","config"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}