{"record":{"id":"7aa3f78bcfac1544","repo":"PaddlePaddle/PaddleOCR","slug":"the-input-data-is-inconsistent-with-expectations-7aa3f7","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_det/module.py","lineNumber":114,"sourceCode":"            images.append(img)\n        return images\n\n    def predict(self, images=[], paths=[]):\n        \"\"\"\n        Get the text box 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 text detection box 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            dt_boxes, elapse = self.text_detector(img)\n            logger.info(\"Predict time : {}\".format(elapse))\n\n            rec_res_final = []\n            for dno in range(len(dt_boxes)):\n                rec_res_final.append(\n                    {\"text_region\": dt_boxes[dno].astype(np.int32).tolist()}","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/deploy/hubserving/ocr_det/module.py#L96-L132","documentation":"Raised by the ocr_det hubserving module's predict method when input validation fails. The API contract is: exactly one of `images` (list of HxWxC numpy arrays) or `paths` (list of path strings), non-empty and of list type. Everything else hits the else branch and raises TypeError.","triggerScenarios":"predict called with both images and paths populated, both empty, a non-list value for either argument, or images supplied via paths (or vice versa).","commonSituations":"Client sends {\"images\": [], \"paths\": []}; a request payload built by copying a template that includes both keys; passing a tuple or generator instead of a list when calling the module in-process.","solutions":["Populate exactly one field with a non-empty list and drop the other from the payload entirely.","Check the request JSON before sending: exactly one of images/paths present, and it is an array with length >= 1.","In-process callers: pass lists explicitly, e.g. predict(images=[np.ndarray], paths=[])."],"exampleFix":"# before\npayload = {\"images\": imgs, \"paths\": [\"extra.jpg\"]}  # both -> TypeError\n\n# after\npayload = {\"images\": imgs}\n# or\npayload = {\"paths\": [\"extra.jpg\"]}","handlingStrategy":"validation","validationCode":"def valid_det_payload(data: dict) -> bool:\n    has_img = isinstance(data.get(\"images\"), list) and data[\"images\"]\n    has_path = isinstance(data.get(\"paths\"), list) and data[\"paths\"]\n    return has_img != has_path  # exactly one true","typeGuard":"from typing import Any\n\ndef xor_payload(images: Any, paths: Any) -> bool:\n    ok_img = isinstance(images, list) and len(images) > 0\n    ok_path = isinstance(paths, list) and len(paths) > 0\n    return ok_img ^ ok_path","tryCatchPattern":"try:\n    res = mod.predict(images=images, paths=paths)\nexcept TypeError as e:\n    if \"inconsistent\" in str(e):\n        raise ValueError(\"send exactly one of images[] or paths[]\") from e\n    raise","preventionTips":["Treat images and paths as mutually exclusive in the client type definitions.","Reject empty batches upstream before they reach the serving module.","Keep a canonical example payload in the service docs and test against it."],"tags":["paddleocr","hubserving","input-validation","ocr-det"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}