{"record":{"id":"0cdea4cfd1e17a8b","repo":"PaddlePaddle/PaddleOCR","slug":"the-input-data-is-inconsistent-with-expectations-0cdea4","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_system/module.py","lineNumber":114,"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            # parse result\n            res_final = []","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/deploy/hubserving/structure_system/module.py#L96-L132","documentation":"Raised by the structure_system hubserving module's predict method when the images/paths contract is broken. Exactly one non-empty list is accepted — `images` (list of numpy arrays) or `paths` (list of path strings) — and any other input combination raises this TypeError before inference.","triggerScenarios":"predict called with images and paths both non-empty, both empty, or either argument not a list.","commonSituations":"Document-analysis pipelines POSTing both keys for convenience; frontends that default missing fields to empty lists and accidentally send both; API gateways merging payload templates.","solutions":["Ensure the request contains exactly one populated array field.","Default the other field to an empty list in direct Python calls: predict(images=[...], paths=[]).","Log the payload before sending to catch template-merge mistakes."],"exampleFix":"# before\npayload = {\"images\": imgs, \"paths\": paths}  # both -> TypeError\n\n# after\npayload = {\"images\": imgs} if imgs else {\"paths\": paths}","handlingStrategy":"validation","validationCode":"def valid_struct_payload(data: dict) -> bool:\n    imgs, paths = data.get(\"images\", []), data.get(\"paths\", [])\n    return (imgs and not paths) or (paths and not imgs)\n\nassert valid_struct_payload(payload), \"send images XOR paths\"","typeGuard":"def payload_ok(images, paths) -> bool:\n    return bool(images) != bool(paths)","tryCatchPattern":"try:\n    res = mod.predict(images=images, paths=paths)\nexcept TypeError as e:\n    if \"inconsistent\" in str(e):\n        log.warning(\"bad payload: images=%r paths=%r\", bool(images), bool(paths))\n        return [], 400\n    raise","preventionTips":["Log the payload keys (not contents) on every failed request for quick triage.","Gateways should enforce exactly-one-of semantics per module docs.","Keep e2e tests for both input modes (images and paths) to catch contract drift."],"tags":["paddleocr","ppstructure","hubserving","input-validation"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}