selection-conflicting
The options of a read or an observation cannot be combined.
- Routes:
read-eventsandobserve-events - Description:
- for
lowerBoundtogether withfromLatestEvent:selection is conflicting: lowerBound and fromLatestEvent cannot be combined - for
fromLatestEventtogether with the orderantichronological, when reading:selection is conflicting: fromLatestEvent requires chronological order
- for
- Details:
fields, the options that cannot be combined, as a list:["lowerBound", "fromLatestEvent"]or["order", "fromLatestEvent"].
Why It Happens#
Both lowerBound and fromLatestEvent say where a read or an observation starts: lowerBound at an event ID, fromLatestEvent at the latest event of a type in a subject. There can only be one start, so the two cannot be combined. A typical cause is a client that resumes after a lost connection by adding a lowerBound to a request that already has fromLatestEvent.
When reading, fromLatestEvent also requires chronological order, the default, so a read with order set to antichronological is refused as well. If a read has both conflicts, the error names lowerBound. These options are checked only once every value of the request has passed, so a value that is wrong, such as a bound without its type, is reported first.
How to Fix It#
Use either lowerBound or fromLatestEvent. To resume after a lost connection, replace fromLatestEvent with a lowerBound that is exclusive at the ID of the last event you received. To read from the latest event of a type, leave out order or set it to chronological, and reverse the events in your client if you need the newest first. Sending the same request again fails the same way.
Example#
To read the events of /books/42 with both a lowerBound and fromLatestEvent, 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/selection-conflicting",
"description": "selection is conflicting: lowerBound and fromLatestEvent cannot be combined",
"details": {
"fields": [
"lowerBound",
"fromLatestEvent"
]
}
}
}