{"record":{"id":"b23bafe9622d5cc9","repo":"PaddlePaddle/PaddleOCR","slug":"asset-assetname-references-unknown-model-asse","errorCode":null,"errorMessage":"Asset \"${assetName}\" references unknown model asset \"${asset}\".","messagePattern":"Asset \"(.+?)\" references unknown model asset \"(.+?)\"\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"paddleocr-js/packages/core/src/resources/model-asset.ts","lineNumber":64,"sourceCode":"  bytes: number;\n}\n\n// --- Validation helpers ---\n\nfunction isNonEmptyString(value: unknown): value is string {\n  return typeof value === \"string\" && value.length > 0;\n}\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n  return Boolean(value && typeof value === \"object\" && !Array.isArray(value));\n}\n\nexport function normalizeModelAsset(assetName: string, asset: unknown): ModelAsset {\n  if (isNonEmptyString(asset)) {\n    const resolvedAsset = DEFAULT_MODEL_ASSETS[asset];\n    // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- runtime guard for missing Record key\n    if (!resolvedAsset) {\n      throw new Error(`Asset \"${assetName}\" references unknown model asset \"${asset}\".`);\n    }\n    return { url: resolvedAsset.url };\n  }\n\n  if (!isObject(asset)) {\n    throw new Error(`Asset \"${assetName}\" must be an object.`);\n  }\n  if (!isNonEmptyString(asset.url)) {\n    throw new Error(`Asset \"${assetName}\" must define url.`);\n  }\n\n  return {\n    url: asset.url\n  };\n}\n\nexport function normalizeAssets(\n  assets: Record<string, unknown> | undefined","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/paddleocr-js/packages/core/src/resources/model-asset.ts#L46-L82","documentation":"Thrown by normalizeModelAsset() when an assets entry is a string shorthand (e.g. \"pp-ocr-v4-det\") that does not match any key in DEFAULT_MODEL_ASSETS. The library supports referencing built-in model bundles by name; an unrecognized name fails fast instead of silently producing an invalid URL. A typo or a version mismatch between the library and the name you use is the usual cause.","triggerScenarios":"Passing { det: { modelPath: ... }, assets: { det: \"pp-ocr-v5-det\" } } where that key is not in DEFAULT_MODEL_ASSETS for the installed package version; copy-pasting a model name from newer docs into an older @paddleocr/core release.","commonSituations":"Upgrading docs/examples to a new model generation while the installed npm package is older; typos like \"ppocr-v4-det\"; custom names expected to work as aliases.","solutions":["Check the DEFAULT_MODEL_ASSETS keys exported by your installed package version and use an exact name","Upgrade @paddleocr/core to the version whose built-in assets include the model you want","Replace the shorthand with an explicit object: { url: \"https://.../model.tar\" }"],"exampleFix":"// before\nconst ocr = await PaddleOCR.create({ assets: { det: \"pp-ocr-v4-detect\" } }); // typo: unknown asset\n\n// after\nconst ocr = await PaddleOCR.create({\n  assets: { det: { url: \"https://your-host/paddle-ocr-v4-det.tar\" } }\n});","handlingStrategy":"type-guard","validationCode":"import { DEFAULT_MODEL_ASSETS } from \"@paddleocr/core\";\nconst isKnownPreset = (v: string): boolean =>\n  Object.prototype.hasOwnProperty.call(DEFAULT_MODEL_ASSETS, v);","typeGuard":"function isModelAssetPreset(value: unknown, registry: Record<string, unknown>): value is string {\n  return typeof value === \"string\" && value in registry;\n}","tryCatchPattern":null,"preventionTips":["Validate preset names against DEFAULT_MODEL_ASSETS of the installed version","Prefer explicit { url } objects for pinning model bundles","Add a unit test asserting the preset names your config uses exist"],"tags":["config","validation","model-assets","typo"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}