event-id-malformed
An event ID in the request is not a non-negative integer written without a sign or a leading zero.
- Routes:
write-events,read-events,observe-events,audit-history, andcreate-backup - Description:
event ID is malformed: expected a non-negative integer of at most 9223372036854775807 in a string, such as '42' - Details:
value, the ID as the request gave it. When reading or observing events, alsobound, the bound it belongs to,lowerBoundorupperBound. When writing events, alsoprecondition, the place of the precondition in its list, counting from 0.
Why It Happens#
An event ID is an integer from 0 to 9223372036854775807, written as a string of digits without a sign or a leading zero, such as "42". The database reports this error for an ID that cannot be read as an integer, such as "4.2" or "latest", that is negative, such as "-1", that is written with a sign, a leading zero, or white space, such as "+5", "007", or " 5", or that is larger than 9223372036854775807. It concerns the same IDs as event-id-missing: the bounds of a read or an observation, the eventId of an isSubjectOnEventId precondition, and the id in lastAuditedEvent or lastBackedUpEvent. An ID sent as a JSON number, such as 42, does not get this far: the database rejects the request with 400 Bad Request.
A typical cause is a lower bound of "-1", meant to read from before the first event, which has the ID 0.
How to Fix It#
Send the ID as a string of digits without a sign or a leading zero, as the database writes it, such as "42". To read from the first event, leave out the lower bound, or make it "0" and inclusive. Sending the same request again fails the same way, since the error depends on the request alone.
Example#
To read the events of /books/42 with a lowerBound whose ID is -1, 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/event-id-malformed",
"description": "event ID is malformed: expected a non-negative integer of at most 9223372036854775807 in a string, such as '42'",
"details": {
"bound": "lowerBound",
"value": "-1"
}
}
}