Lightning-AI/pytorch-lightning · error · Exception
Your provided payload {payload} should have a field named "b
Error message
Your provided payload {payload} should have a field named "body". What it means
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.
Source
Thrown at src/lightning/pytorch/serve/servable_module_validator.py:117
process.start()
servable_module.trainer = trainer
ready = False
t0 = time.time()
while not ready:
with contextlib.suppress(requests.exceptions.ConnectionError):
resp = requests.get(f"http://{self.host}:{self.port}/ping")
ready = resp.status_code == 200
if time.time() - t0 > self.timeout:
process.kill()
raise Exception(f"The server didn't start within {self.timeout} seconds.")
time.sleep(0.1)
payload = servable_module.configure_payload()
if "body" not in payload:
raise Exception(f'Your provided payload {payload} should have a field named "body".')
self.resp = requests.post(f"http://{self.host}:{self.port}/serve", json=payload)
process.kill()
if is_overridden("configure_response", servable_module, ServableModule):
response = servable_module.configure_response()
if self.resp.json() != response:
raise Exception(f"The expected response {response} doesn't match the generated one {self.resp.json()}.")
if self.exit_on_failure and not self.successful:
raise MisconfigurationException("The model isn't servable. Investigate the traceback and try again.")
if self.successful:
_logger.info(f"Your model is servable and the received payload was {self.resp.json()}.")
@property
def successful(self) -> Optional[bool]:
"""Returns whether the model was successfully served."""View on GitHub (pinned to 9fed5c27d2)
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
Example fix
// before
def configure_payload(self):
return {"x": [1.0, 2.0]}
// after
def configure_payload(self):
return {"body": {"x": [1.0, 2.0]}} Defensive patterns
Strategy: validation
Validate before calling
payload = model.configure_payload()
assert isinstance(payload, dict) and "body" in payload, \
f'configure_payload must return {{"body": ...}}, got {payload}' Type guard
def valid_payload(p) -> bool:
return isinstance(p, dict) and "body" in p and isinstance(p["body"], dict) Prevention
- Always wrap inputs under "body"
- Add a fast unit test for configure_payload shape
When it happens
Trigger: configure_payload returns a flat dict like {"x": ...} instead of {"body": {"x": ...}}, or returns the raw tensor/list payload without wrapping.
Common situations: Writing the payload by trial without reading the ServableModule contract; changing payload shape after adding new inputs and dropping the wrapper.
Related errors
- The `configure_payload` method needs to be overridden.
- The `configure_serialization` method needs to be overridden.
- The `serve_step` method needs to be overridden.
- The server didn't start within {self.timeout} seconds.
- The expected response {response} doesn't match the generated
AI-assisted analysis of Lightning-AI/pytorch-lightning@9fed5c27d2 (2026-08-28).
Data as JSON: /api/errors/2ee6104319909e05.
Report an issue: GitHub.