{"record":{"id":"97ec78812e653eac","repo":"PaddlePaddle/PaddleOCR","slug":"kind-model-requires-a-non-empty-model-entry-p","errorCode":null,"errorMessage":"${kind} model requires a non-empty ${MODEL_ENTRY_PATHS.model} resource.","messagePattern":"(.+?) model requires a non-empty (.+?) resource\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"paddleocr-js/packages/core/src/resources/model-asset.ts","lineNumber":104,"sourceCode":"  if (assetEntries.length === 0) {\n    throw new Error(\"Assets must define at least one asset.\");\n  }\n\n  return Object.fromEntries(\n    assetEntries.map(([assetName, asset]) => [assetName, normalizeModelAsset(assetName, asset)])\n  );\n}\n\n// --- Model loading ---\n\nexport function getModelEntryPath(slot: string): string | null {\n  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  }","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/paddleocr-js/packages/core/src/resources/model-asset.ts#L86-L122","documentation":"Thrown by assertModelResourceSlot() when the \"model\" slot of loaded model resources is not a non-empty Uint8Array. The tar bundle must contain the model entry file (path from MODEL_ENTRY_PATHS.model) with at least one byte. It fires when the archive was extracted but the model entry is missing/empty - i.e. a wrong or corrupt bundle passed the download check but does not contain the expected ONNX/model file.","triggerScenarios":"Pointing assets at a tar that contains only a config (e.g. a params-only bundle), an HTML error page tarred by a bad CDN, or a truncated upload; manually constructing resources where the model bytes were never set.","commonSituations":"Self-hosting model bundles and packaging the wrong files; CDN returning a soft-200 error body; partial downloads saved to cache; custom pipeline code that populates resources itself.","solutions":["Verify the tar actually contains the model entry path (inspect with `tar -tf model.tar`) and re-package with the expected file layout","Point assets at the official bundle URL for your model","Clear any cached downloads and re-fetch; check the bundle size against the published size","If building resources programmatically, ensure the model slot holds non-empty Uint8Array bytes"],"exampleFix":"# before (bundle missing model file)\ntar -tf det.tar\n# config/inference.yml\n\n# after\n# include the model weights file at the expected entry path\ntar -tf det.tar\n# inference.pdmodel / onnx model file present\n# then: assets: { det: { url: \"https://host/det.tar\" } }","handlingStrategy":"validation","validationCode":"function isValidModelSlot(v: unknown): boolean {\n  return v instanceof Uint8Array && v.byteLength > 0;\n}\n// before assertModelResources: every resources.model passes isValidModelSlot","typeGuard":"function isNonEmptyBytes(v: unknown): v is Uint8Array {\n  return v instanceof Uint8Array && v.byteLength > 0;\n}","tryCatchPattern":null,"preventionTips":["Inspect bundles with tar -tf before shipping custom URLs","Verify downloaded byte length matches the published model size","Cache only validated downloads"],"tags":["model","validation","tar","packaging"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}