{"record":{"id":"9177d83066827117","repo":"PaddlePaddle/PaddleOCR","slug":"the-input-data-is-inconsistent-with-expectations-9177d8","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/kie_ser_re/module.py","lineNumber":115,"sourceCode":"                continue\n            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        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            print(img.shape)\n            starttime = time.time()\n            re_res, _ = self.ser_re_predictor(img)\n            print(re_res)\n            elapse = time.time() - starttime\n            logger.info(\"Predict time: {}\".format(elapse))\n            all_results.append(re_res)","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/deploy/hubserving/kie_ser_re/module.py#L97-L133","documentation":"Raised by the kie_ser_re hubserving module's predict method when the request payload does not match the expected shape. The module accepts input either as raw image arrays (`images`) or as file paths (`paths`) — exactly one of the two, and it must be a non-empty Python list. Any other combination (both set, both empty, wrong types) falls through to this TypeError.","triggerScenarios":"Calling predict with both `images` and `paths` non-empty, with both empty, with `images`/`paths` as a non-list (e.g. a single numpy array or string instead of a list), or passing keyword arguments the if/elif chain does not accept.","commonSituations":"POSTing a hubserving JSON body like {\"images\": [...], \"paths\": [...]} (both keys), sending a bare string path instead of a one-element list, or reusing a client written for a different PaddleOCR serving module that has a different payload contract.","solutions":["Send exactly one field: either {\"images\": [<numpy arrays>} or {\"paths\": [\"a.jpg\"]}, never both, never neither.","Ensure the chosen field is a Python list (JSON array) with at least one element.","If calling the class directly, call predict(images=[img], paths=[]) or predict(images=[], paths=[...])."],"exampleFix":"# before\nres = module.predict(images=[img], paths=[\"a.jpg\"])  # both set -> TypeError\n\n# after\nres = module.predict(images=[img], paths=[])\n# or\nres = module.predict(images=[], paths=[\"a.jpg\"])","handlingStrategy":"validation","validationCode":"def valid_kie_payload(images, paths) -> bool:\n    return (\n        isinstance(images, list) and images and not paths\n    ) or (\n        isinstance(paths, list) and paths and not images\n    )\n\nassert valid_kie_payload(images, paths), \"send exactly one non-empty list: images XOR paths\"","typeGuard":"from typing import Any, List\n\ndef is_valid_images_list(v: Any) -> bool:\n    return isinstance(v, list) and len(v) > 0 and all(\n        hasattr(im, \"shape\") for im in v\n    )\n\ndef is_valid_paths_list(v: Any) -> bool:\n    return isinstance(v, list) and len(v) > 0 and all(\n        isinstance(p, str) for p in v\n    )","tryCatchPattern":"try:\n    res = module.predict(images=images, paths=paths)\nexcept TypeError as e:\n    if \"inconsistent with expectations\" in str(e):\n        raise ValueError(\"payload must be exactly one non-empty list: images XOR paths\") from e\n    raise","preventionTips":["Build request payloads with a helper that sets exactly one of images/paths.","Keep client-side schemas in sync with the hubserving module contract.","Add an integration test that posts a minimal valid payload after every client change."],"tags":["paddleocr","hubserving","input-validation","kie"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}