{"record":{"id":"fac690668a139c30","repo":"PaddlePaddle/PaddleOCR","slug":"modulepath-model-name-must-be-provided-when-m","errorCode":null,"errorMessage":"${modulePath}.model_name must be provided when ${modulePath}.model_dir is set.","messagePattern":"(.+?)\\.model_name must be provided when (.+?)\\.model_dir is set\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"paddleocr-js/packages/core/src/pipelines/ocr/config.ts","lineNumber":105,"sourceCode":"  if (!isPlainObject(input)) {\n    throw new Error(\"OCR pipeline config must be an object or YAML text.\");\n  }\n  return input;\n}\n\nfunction addFeatureWarning(warnings: string[], featureName: string, reason?: string): void {\n  warnings.push(\n    `${featureName} is not yet supported in PaddleOCR.js${reason ? `: ${reason}` : \"\"}.`\n  );\n}\n\nfunction getModuleModelName(moduleConfig: YamlObject | null): string | null {\n  return typeof moduleConfig?.model_name === \"string\" ? moduleConfig.model_name : null;\n}\n\nfunction validateModuleAsset(modulePath: string, modelName: string | null): void {\n  if (!modelName) {\n    throw new Error(\n      `${modulePath}.model_name must be provided when ${modulePath}.model_dir is set.`\n    );\n  }\n}\n\nfunction getModuleAsset(\n  assetName: string,\n  modulePath: string,\n  moduleConfig: YamlObject | null\n): ModelAsset | null {\n  if (moduleConfig?.model_dir == null) {\n    return null;\n  }\n  if (isPlainObject(moduleConfig.model_dir)) {\n    const asset = normalizeModelAsset(assetName, moduleConfig.model_dir);\n    validateModuleAsset(modulePath, getModuleModelName(moduleConfig));\n    return asset;\n  }","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/paddleocr-js/packages/core/src/pipelines/ocr/config.ts#L87-L123","documentation":"Thrown by validateModuleAsset() during config normalization: a module (e.g. SubModules.TextDetection) sets model_dir, but model_name is absent. model_name is required alongside model_dir so the resolved asset can be identified and registered; the combination model_dir-without-model_name is treated as an incomplete module definition.","triggerScenarios":"A pipeline config with SubModules.TextDetection.model_dir set (as an asset descriptor) but no model_name key; model_name misspelled (model_Name, modelName); model_name present but not a string (null, number) so getModuleModelName returns null.","commonSituations":"Hand-writing a browser pipeline config and copying only the model_dir block; trimming configs for size and dropping model_name; converting a Python-side config where the field was optional.","solutions":["Add model_name next to model_dir in the offending module block (see the modulePath in the message)","Check the exact key spelling and that the value is a string","If you do not want to override the model, remove model_dir entirely and let defaults apply"],"exampleFix":"# before\nSubModules:\n  TextDetection:\n    model_dir:\n      url: \"https://cdn/models/det.onnx\"\n\n# after\nSubModules:\n  TextDetection:\n    model_name: PP-OCRv5_mobile_det\n    model_dir:\n      url: \"https://cdn/models/det.onnx\"","handlingStrategy":"validation","validationCode":"for (const [path, mod] of [[\"TextDetection\", subModules.TextDetection], [\"TextRecognition\", subModules.TextRecognition]] as const) {\n  if (mod?.model_dir != null && typeof mod.model_name !== \"string\") {\n    throw new Error(`${path}.model_name is required when model_dir is set`);\n  }\n}","typeGuard":"function isCompleteModule(mod: unknown): boolean {\n  const m = mod as Record<string, unknown> | null;\n  return m == null || m.model_dir == null || typeof m.model_name === \"string\";\n}","tryCatchPattern":null,"preventionTips":["Always pair model_dir with model_name in module blocks","Lint pipeline YAML for the model_dir ⇒ model_name rule","Remember removing model_name without removing model_dir breaks the config"],"tags":["paddleocr","config","yaml","model-asset"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}