{"record":{"id":"2ee6104319909e05","repo":"Lightning-AI/pytorch-lightning","slug":"your-provided-payload-payload-should-have-a-fiel","errorCode":null,"errorMessage":"Your provided payload {payload} should have a field named \"body\".","messagePattern":"Your provided payload (.+?) should have a field named \"body\"\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/lightning/pytorch/serve/servable_module_validator.py","lineNumber":117,"sourceCode":"        process.start()\n\n        servable_module.trainer = trainer\n\n        ready = False\n        t0 = time.time()\n        while not ready:\n            with contextlib.suppress(requests.exceptions.ConnectionError):\n                resp = requests.get(f\"http://{self.host}:{self.port}/ping\")\n                ready = resp.status_code == 200\n            if time.time() - t0 > self.timeout:\n                process.kill()\n                raise Exception(f\"The server didn't start within {self.timeout} seconds.\")\n            time.sleep(0.1)\n\n        payload = servable_module.configure_payload()\n\n        if \"body\" not in payload:\n            raise Exception(f'Your provided payload {payload} should have a field named \"body\".')\n\n        self.resp = requests.post(f\"http://{self.host}:{self.port}/serve\", json=payload)\n        process.kill()\n\n        if is_overridden(\"configure_response\", servable_module, ServableModule):\n            response = servable_module.configure_response()\n            if self.resp.json() != response:\n                raise Exception(f\"The expected response {response} doesn't match the generated one {self.resp.json()}.\")\n\n        if self.exit_on_failure and not self.successful:\n            raise MisconfigurationException(\"The model isn't servable. Investigate the traceback and try again.\")\n\n        if self.successful:\n            _logger.info(f\"Your model is servable and the received payload was {self.resp.json()}.\")\n\n    @property\n    def successful(self) -> Optional[bool]:\n        \"\"\"Returns whether the model was successfully served.\"\"\"","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/pytorch/serve/servable_module_validator.py#L99-L135","documentation":"After the server is up, the validator calls model.configure_payload() and POSTs it to /serve. The serving protocol requires the payload to contain a top-level \"body\" field; if it is missing, a generic Exception is raised before the request is sent.","triggerScenarios":"configure_payload returns a flat dict like {\"x\": ...} instead of {\"body\": {\"x\": ...}}, or returns the raw tensor/list payload without wrapping.","commonSituations":"Writing the payload by trial without reading the ServableModule contract; changing payload shape after adding new inputs and dropping the wrapper.","solutions":["Wrap your inputs under a \"body\" key in configure_payload: return {\"body\": {...}}","Make sure keys inside \"body\" match the input deserializer names from configure_serialization"],"exampleFix":"// before\ndef configure_payload(self):\n    return {\"x\": [1.0, 2.0]}\n// after\ndef configure_payload(self):\n    return {\"body\": {\"x\": [1.0, 2.0]}}","handlingStrategy":"validation","validationCode":"payload = model.configure_payload()\nassert isinstance(payload, dict) and \"body\" in payload, \\\n    f'configure_payload must return {{\"body\": ...}}, got {payload}'","typeGuard":"def valid_payload(p) -> bool:\n    return isinstance(p, dict) and \"body\" in p and isinstance(p[\"body\"], dict)","tryCatchPattern":null,"preventionTips":["Always wrap inputs under \"body\"","Add a fast unit test for configure_payload shape"],"tags":["lightning","serving","payload","schema"],"backgroundTag":"payload-schema-validation","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}