{"record":{"id":"34a892ee4d8c2c87","repo":"PaddlePaddle/PaddleOCR","slug":"the-input-data-is-inconsistent-with-expectations-34a892","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/ocr_system/module.py","lineNumber":115,"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            dt_boxes, rec_res, _ = self.text_sys(img)\n            elapse = time.time() - starttime\n            logger.info(\"Predict time: {}\".format(elapse))\n\n            dt_num = len(dt_boxes)\n            rec_res_final = []","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/deploy/hubserving/ocr_system/module.py#L97-L133","documentation":"Raised by the ocr_system hubserving module's predict method when the request violates its input contract. Exactly one of `images` (list of numpy HxWxC arrays) or `paths` (list of path strings) must be a non-empty list; all other inputs reach the else branch and raise TypeError.","triggerScenarios":"predict invoked with images and paths both non-empty, both empty, or either not being a list.","commonSituations":"Posting a request with both keys filled because the client supports both modes; passing a directory path string instead of a list of file paths; empty batch from an upstream image feeder.","solutions":["Send one and only one non-empty array field: {\"images\": [...]} or {\"paths\": [...]}.","Expand directories to explicit file lists client-side before sending.","In-process: call predict(images=[...], paths=[]) or predict(images=[], paths=[...])."],"exampleFix":"# before\npayload = {\"images\": [], \"paths\": []}  # both empty -> TypeError\n\n# after\npayload = {\"paths\": [\"docs/page1.png\", \"docs/page2.png\"]}","handlingStrategy":"validation","validationCode":"def valid_system_payload(data: dict) -> bool:\n    imgs, paths = data.get(\"images\", []), data.get(\"paths\", [])\n    return (bool(imgs) and isinstance(imgs, list) and not paths) or (\n        bool(paths) and isinstance(paths, list) and not imgs\n    )","typeGuard":"def exactly_one_list(a, b) -> bool:\n    a_ok = isinstance(a, list) and len(a) > 0\n    b_ok = isinstance(b, list) and len(b) > 0\n    return a_ok != b_ok","tryCatchPattern":"try:\n    res = mod.predict(images=images, paths=paths)\nexcept TypeError as e:\n    if \"inconsistent\" in str(e):\n        raise ValueError(\"images XOR paths required, got both/neither\") from e\n    raise","preventionTips":["Expand directories into explicit path lists before building requests.","Omit the unused key from JSON payloads rather than sending empty arrays.","Gateway-level schema validation (exactly-one-of) catches bad clients early."],"tags":["paddleocr","hubserving","input-validation","ocr-system"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}