{"record":{"id":"1aab68320125614e","repo":"PaddlePaddle/PaddleOCR","slug":"the-input-data-is-inconsistent-with-expectations-1aab68","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_table/module.py","lineNumber":113,"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 result of chinese texts and save path 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.table_sys(img)\n            elapse = time.time() - starttime\n            logger.info(\"Predict time: {}\".format(elapse))\n\n            all_results.append({\"html\": res[\"html\"]})\n        return all_results","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/deploy/hubserving/structure_table/module.py#L95-L131","documentation":"Raised by the structure_table hubserving module's predict method when the input does not satisfy its contract: exactly one non-empty list of either `images` (numpy arrays) or `paths` (file path strings). All other inputs fall to the else branch and raise TypeError.","triggerScenarios":"predict called with both fields populated, both empty, or a non-list value (bare string, single ndarray) for either argument.","commonSituations":"Table-recognition clients sending {\"paths\": \"table.png\"}; batch jobs that pass images plus their paths together; empty payloads from upstream document splitters.","solutions":["Send exactly one non-empty array field: {\"images\": [...]} or {\"paths\": [...]}.","Wrap single inputs in a one-element list.","Validate the payload shape client-side before POSTing."],"exampleFix":"# before\nres = mod.predict(images=[], paths=\"invoice.png\")  # string -> TypeError\n\n# after\nres = mod.predict(images=[], paths=[\"invoice.png\"])","handlingStrategy":"validation","validationCode":"def valid_table_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_list(v) -> bool:\n    return isinstance(v, list) and len(v) > 0","tryCatchPattern":"try:\n    res = mod.predict(images=images, paths=paths)\nexcept TypeError as e:\n    if \"inconsistent\" in str(e):\n        raise ValueError(\"exactly one non-empty list required: images or paths\") from e\n    raise","preventionTips":["Wrap single paths in lists at the client boundary.","Reject empty batches before they reach the module.","Share payload validation helpers across all table/structure clients."],"tags":["paddleocr","ppstructure","table","hubserving","input-validation"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}