{"record":{"id":"6f4852b2c3f3111a","repo":"PaddlePaddle/PaddleOCR","slug":"unsupported-model-resource-slot-slot","errorCode":null,"errorMessage":"Unsupported model resource slot \"${slot}\".","messagePattern":"Unsupported model resource slot \"(.+?)\"\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"paddleocr-js/packages/core/src/resources/model-asset.ts","lineNumber":116,"sourceCode":"  return MODEL_ENTRY_PATHS[slot] || null;\n}\n\nexport function assertModelResourceSlot(kind: string, slot: string, value: unknown): void {\n  if (slot === \"model\") {\n    if (!(value instanceof Uint8Array) || value.byteLength === 0) {\n      throw new Error(`${kind} model requires a non-empty ${MODEL_ENTRY_PATHS.model} resource.`);\n    }\n    return;\n  }\n\n  if (slot === \"config\") {\n    if (typeof value !== \"string\" || value.trim().length === 0) {\n      throw new Error(`${kind} model requires a non-empty ${MODEL_ENTRY_PATHS.config} resource.`);\n    }\n    return;\n  }\n\n  throw new Error(`Unsupported model resource slot \"${slot}\".`);\n}\n\nexport function assertModelResources(kind: string, resources: Record<string, unknown>): void {\n  for (const [slot, value] of Object.entries(resources)) {\n    assertModelResourceSlot(kind, slot, value);\n  }\n}\n\n// --- Model loading (fetch + tar extraction) ---\n\nimport { extractTarEntries, pickTarEntry } from \"./tar\";\n\nexport async function loadModelAsset(\n  asset: ModelAsset,\n  fetchImpl: typeof fetch = fetch\n): Promise<ModelLoadResult> {\n  const response = await fetchImpl(asset.url);\n  if (!response.ok) {","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/paddleocr-js/packages/core/src/resources/model-asset.ts#L98-L134","documentation":"Thrown by assertModelResourceSlot() when a resource key other than \"model\" or \"config\" appears in the resources record. The loader only understands these two slots (mapped to MODEL_ENTRY_PATHS entries); any extra key means the resource map was constructed from a bundle or code with unexpected entries, and it is rejected rather than ignored to surface packaging bugs.","triggerScenarios":"Populating resources with extra keys such as { model, config, vocab } or { model, config, metadata: ... }; looping over tar entries and passing all of them as resources instead of only the two recognized slots.","commonSituations":"Custom loaders that extract every tar entry into the resources map; bundles that add auxiliary files and consumer code copying them wholesale.","solutions":["Pass only the two recognized slots: { model: Uint8Array, config: string }","Filter extracted tar entries down to MODEL_ENTRY_PATHS.model and .config before validation","Update packaging so auxiliary files are not fed into assertModelResources"],"exampleFix":"# before (python/js pseudo)\nresources = {e.name: e.data for e in tar_entries}  # includes extra slots -> throws\n\n# after\nresources = {\n  \"model\": pick(tar_entries, \"inference.pdmodel\"),\n  \"config\": text_of(pick(tar_entries, \"inference.yml\")),\n}","handlingStrategy":"validation","validationCode":"const ALLOWED_SLOTS = new Set([\"model\", \"config\"]);\nfunction onlyAllowedSlots(resources: Record<string, unknown>): boolean {\n  return Object.keys(resources).every(k => ALLOWED_SLOTS.has(k));\n}","typeGuard":"type ModelSlots = { model: Uint8Array; config: string };\nfunction isModelSlots(v: Record<string, unknown>): v is ModelSlots {\n  const keys = Object.keys(v);\n  return keys.every(k => k === \"model\" || k === \"config\") &&\n    v.model instanceof Uint8Array && typeof v.config === \"string\";\n}","tryCatchPattern":null,"preventionTips":["Map only MODEL_ENTRY_PATHS entries into the resources record","Do not forward every tar entry as a resource slot"],"tags":["model","validation","resources","packaging"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}