{"record":{"id":"becfbea6e89f8c1b","repo":"PaddlePaddle/PaddleOCR","slug":"ocr-pipeline-config-text-must-decode-to-an-object","errorCode":null,"errorMessage":"OCR pipeline config text must decode to an object.","messagePattern":"OCR pipeline config text must decode to an object\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"paddleocr-js/packages/core/src/pipelines/ocr/config.ts","lineNumber":83,"sourceCode":"  if (textType !== \"general\") {\n    return runtimeDefaults;\n  }\n  return {\n    text_det_limit_side_len: runtimeDefaults.text_det_limit_side_len ?? 960,\n    text_det_limit_type: runtimeDefaults.text_det_limit_type ?? \"max\",\n    text_det_max_side_limit: runtimeDefaults.text_det_max_side_limit ?? 4000,\n    text_det_thresh: runtimeDefaults.text_det_thresh ?? 0.3,\n    text_det_box_thresh: runtimeDefaults.text_det_box_thresh ?? 0.6,\n    text_det_unclip_ratio: runtimeDefaults.text_det_unclip_ratio ?? 2.0,\n    text_rec_score_thresh: runtimeDefaults.text_rec_score_thresh ?? 0\n  };\n}\n\nfunction parsePipelineConfigInput(input: unknown): YamlObject {\n  if (typeof input === \"string\") {\n    const parsed = yaml.load(input);\n    if (!isPlainObject(parsed)) {\n      throw new Error(\"OCR pipeline config text must decode to an object.\");\n    }\n    return parsed;\n  }\n  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}","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/paddleocr-js/packages/core/src/pipelines/ocr/config.ts#L65-L101","documentation":"Thrown by parsePipelineConfigInput() when the input is a string but yaml.load() does not yield a plain object. YAML text that decodes to null, a number, a boolean, an array, or is effectively empty fails this check — the pipeline config must be a YAML mapping at the top level.","triggerScenarios":"Passing \"null\", \"\" (empty string), \"42\", \"- item\" (a YAML list), or a multi-document YAML string to parseOcrPipelineConfigText/normalizeOcrPipelineConfig; a file read that returned only whitespace or a placeholder.","commonSituations":"Reading a config file that is empty or contains only comments; pasting an example YAML fragment that is a list of keys; fetch() of the config URL returning an error page body that happens to parse as a scalar.","solutions":["Print the input string and run it through any YAML validator — confirm it decodes to a mapping","Ensure the config starts with mapping keys (e.g. pipeline_name:, SubModules:) and no leading '- '","If the file may be empty, check its length/content before parsing","Verify a remote fetch actually returned YAML (status 200, correct content) before parsing"],"exampleFix":"# before (config text)\n- pipeline_name\n- SubModules\n\n# after (config text)\npipeline_name: OCR\nSubModules:\n  TextDetection: {}\n  TextRecognition: {}","handlingStrategy":"validation","validationCode":"import { parse } from \"yaml\";\nconst doc = yamlText.trim() ? parse(yamlText) : undefined;\nif (typeof doc !== \"object\" || doc === null || Array.isArray(doc)) {\n  throw new Error(\"Pipeline config text is not a YAML mapping\");\n}","typeGuard":"function isYamlMapping(doc: unknown): doc is Record<string, unknown> {\n  return typeof doc === \"object\" && doc !== null && !Array.isArray(doc);\n}","tryCatchPattern":null,"preventionTips":["Validate config text parses to a mapping before passing it to the pipeline","Check fetched config responses for non-200 status before parsing the body","Keep example configs as mappings, never top-level lists"],"tags":["paddleocr","config","yaml","validation"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}