{"record":{"id":"d40c11256ae140ef","repo":"PaddlePaddle/PaddleOCR","slug":"the-input-data-is-inconsistent-with-expectations-d40c11","errorCode":null,"errorMessage":"The input data is inconsistent with expectations.","messagePattern":"The input data is inconsistent with expectations\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"deploy/hubserving/structure_layout/module.py","lineNumber":111,"sourceCode":"            images.append(img)\n        return images\n\n    def predict(self, images=[], paths=[]):\n        \"\"\"\n        Get the chinese texts in the predicted images.\n        Args:\n            images (list(numpy.ndarray)): images data, shape of each is [H, W, C]. If images not paths\n            paths (list[str]): The paths of images. If paths not images\n        Returns:\n            res (list): The layout results of images.\n        \"\"\"\n\n        if images != [] and isinstance(images, list) and paths == []:\n            predicted_data = images\n        elif images == [] and isinstance(paths, list) and paths != []:\n            predicted_data = self.read_images(paths)\n        else:\n            raise TypeError(\"The input data is inconsistent with expectations.\")\n\n        assert (\n            predicted_data != []\n        ), \"There is not any image to be predicted. Please check the input data.\"\n\n        all_results = []\n        for img in predicted_data:\n            if img is None:\n                logger.info(\"error in loading image\")\n                all_results.append([])\n                continue\n            starttime = time.time()\n            res, _ = self.layout_predictor(img)\n            elapse = time.time() - starttime\n            logger.info(\"Predict time: {}\".format(elapse))\n\n            for item in res:\n                item[\"bbox\"] = item[\"bbox\"].tolist()","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/deploy/hubserving/structure_layout/module.py#L93-L129","documentation":"Raised by the structure_layout hubserving module's predict method when input validation fails. The module needs exactly one non-empty list — `images` (numpy arrays) or `paths` (file path strings); the if/elif chain rejects every other shape with this TypeError.","triggerScenarios":"predict called with both fields set, both empty, or a non-list value (bare string path, single ndarray) for either argument.","commonSituations":"Layout-analysis requests that mirror a different module's payload format; clients that always include both keys with defaults; feeding PDF page images without wrapping them in a list.","solutions":["Send exactly one non-empty array: {\"images\": [...]} or {\"paths\": [...]}.","Remove the unused key from the JSON body entirely.","For direct calls, pass predict(images=[...], paths=[]) or the mirror form."],"exampleFix":"# before\nres = mod.predict(images=[], paths=\"page-3.png\")  # string -> TypeError\n\n# after\nres = mod.predict(images=[], paths=[\"page-3.png\"])","handlingStrategy":"validation","validationCode":"def valid_layout_payload(data: dict) -> bool:\n    imgs, paths = data.get(\"images\"), data.get(\"paths\")\n    return (isinstance(imgs, list) and imgs and not paths) or (\n        isinstance(paths, list) and paths and not imgs\n    )","typeGuard":"def is_nonempty_str_list(v) -> bool:\n    return isinstance(v, list) and len(v) > 0 and all(isinstance(s, str) for s in v)","tryCatchPattern":"try:\n    res = mod.predict(images=images, paths=paths)\nexcept TypeError as e:\n    if \"inconsistent\" in str(e):\n        return {\"error\": \"exactly one of images[]/paths[] required\"}, 400\n    raise","preventionTips":["Use one shared payload builder for all hubserving modules.","Never let frontends merge payload templates that contain both keys.","Document the XOR contract at the client boundary."],"tags":["paddleocr","hubserving","input-validation","layout"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}