from-latest-event-incomplete
fromLatestEvent leaves out its subject, its type, or ifEventIsMissing.
- Routes:
read-eventsandobserve-events - Description:
- without
subject:fromLatestEvent is incomplete: expected a subject - without
type:fromLatestEvent is incomplete: expected a type - without
ifEventIsMissing:fromLatestEvent is incomplete: expected ifEventIsMissing
- without
- Details:
field, the field that is left out:subject,type, orifEventIsMissing.
Why It Happens#
The option fromLatestEvent starts a read or an observation at the latest event of a type in a subject, and it needs all three of its fields: the subject and the type of that event, and ifEventIsMissing, which says what to do if there is no such event. None of them has a default, and an empty string counts as left out. A typical cause is a fromLatestEvent that names the subject and the type, but leaves out ifEventIsMissing.
The fields are checked in the order subject, type, ifEventIsMissing, and the error names the first that is missing. Their values are checked only afterwards: an unknown value of ifEventIsMissing is reported as if-event-is-missing-unknown, a subject that is not valid as subject-malformed, and a type that is not valid as event-type-malformed.
How to Fix It#
Send fromLatestEvent with all three fields. For ifEventIsMissing, send read-everything or read-nothing when reading, and read-everything or wait-for-event when observing. Sending the same request again fails the same way.
Example#
To read the events of /books/42 from its latest io.eventsourcingdb.library.book-borrowed event, without ifEventIsMissing, 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/from-latest-event-incomplete",
"description": "fromLatestEvent is incomplete: expected ifEventIsMissing",
"details": {
"field": "ifEventIsMissing"
}
}
}