Docs / EventSourcingDB / Errors / events-missing

events-missing

A write holds no events.

  • Route: write-events
  • Description: events are missing: expected at least one event
  • Details: None; details is an empty object.

Why It Happens#

A write stores one or more events at once, all of them or none. The database reports this error when events is left out or is an empty array. A typical cause is a client that sends a write even when there is nothing to write, for example after a command that changed nothing, or one that sends only preconditions to find out whether they hold.

The database checks this before anything else of the write, once the values of the preconditions are checked: before whether it takes writes at all, before its capacity, and before any precondition. So a write without events reports this error in read-only mode as well, rather than store-read-only, and rather than precondition-violated where a precondition does not hold. With an isEventQlQueryTrue precondition, it is answered without running the query, so that it holds up no other write. Only an expired license comes before it, as license-invalid, since the license is checked before any value of the request.

How to Fix It#

Send at least one event with every write, and skip the request when there is nothing to write. Sending the same request again fails the same way, since the error depends on the request alone.

Example#

For a write whose events is an empty array, 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/events-missing",
    "description": "events are missing: expected at least one event",
    "details": {}
  }
}