data-missing
An event leaves out its data.
- Route:
write-events - Description:
data is missing: expected a JSON object - Details:
event, the place of the event in its list, counting from 0.
Why It Happens#
Every event carries its payload in data, which is a JSON object, see CloudEvents. The database reports this error when an event of a write leaves out data. An event that has nothing to say beyond its subject and type still needs data, as an empty object.
A typical cause is a serializer that leaves out empty fields, and with them the data of an event that has none. A data of null, or of another JSON type than an object, such as a string, does not get this far: the database rejects the request with 400 Bad Request, see Requests.
How to Fix It#
Send data with every event, as {} where the event carries nothing, and make your serializer keep it. Sending the same request again fails the same way, since the error depends on the request alone.
Example#
For a write whose first event leaves out its data, EventSourcingDB answers with this error, as a line of the stream, and then ends the stream with its end item:
{
"type": "error",
"data": {
"code": "https://docs.eventsourcingdb.io/errors/data-missing",
"description": "data is missing: expected a JSON object",
"details": {
"event": 0
}
}
}