{"record":{"id":"1af5d6b1dfe5e8ad","repo":"PaddlePaddle/PaddleOCR","slug":"the-input-data-is-inconsistent-with-expectations-1af5d6","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_rec/module.py","lineNumber":112,"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        img_list = []\n        for img in predicted_data:\n            if img is None:\n                continue\n            img_list.append(img)\n\n        rec_res_final = []\n        try:\n            rec_res, predict_time = self.text_recognizer(img_list)\n            for dno in range(len(rec_res)):\n                text, score = rec_res[dno]\n                rec_res_final.append(\n                    {","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/deploy/hubserving/ocr_rec/module.py#L94-L130","documentation":"Raised by the ocr_rec hubserving module's predict method when the images/paths input contract is violated. The method requires exactly one non-empty list: either `images` (list of numpy image arrays) or `paths` (list of image file paths). Any other combination raises TypeError before any inference runs.","triggerScenarios":"Both images and paths supplied; both empty; either argument not a list (e.g. paths as a bare string or images as a single ndarray).","commonSituations":"Sending a recognition request with {\"paths\": \"img.jpg\"} instead of an array; batching scripts that pass images and paths together for logging purposes; empty request bodies from upstream services.","solutions":["Send exactly one key as a non-empty array: {\"images\": [...]} xor {\"paths\": [...]}.","Wrap scalar inputs in a one-element list.","Validate the payload client-side before POSTing to the served endpoint."],"exampleFix":"# before\nres = mod.predict(images=arr, paths=[])  # ndarray, not list -> TypeError\n\n# after\nres = mod.predict(images=[arr], paths=[])","handlingStrategy":"validation","validationCode":"def valid_rec_request(images, paths) -> bool:\n    return (isinstance(images, list) and images and paths == []) or (\n        isinstance(paths, list) and paths and images == []\n    )","typeGuard":"def as_list(v):\n    if isinstance(v, list):\n        return v\n    return [v]  # wrap scalars/arrays so predict never sees a bare value","tryCatchPattern":"try:\n    res = mod.predict(images=images, paths=paths)\nexcept TypeError as e:\n    if \"inconsistent\" in str(e):\n        return [], 400  # bad request, log payload for triage\n    raise","preventionTips":["Normalize inputs through an as_list() helper on the client side.","Assert exactly one input mode in request-building code.","Unit-test the client payload builder against the module contract."],"tags":["paddleocr","hubserving","input-validation","ocr-rec"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}