Docs / EventSourcingDB / Errors / event-type-malformed

event-type-malformed

An event type in the request is not a valid event type.

  • Routes: write-events, read-events, observe-events, read-event-type, and register-event-schema
  • Description: event type is malformed: expected a reverse domain name such as 'io.eventsourcingdb.library.book-acquired'
  • Details: value, the event type as the request gave it. When writing events, also event, the place of the event in its list, counting from 0. When reading or observing events, also option, which is fromLatestEvent.

Why It Happens#

An event type is a reverse domain name of at least three segments, separated by dots, each made of letters, digits, underscores, and hyphens only, where the first segment has at least two characters. A type with fewer segments, such as BookAcquired or io.book-acquired, or with a space, a slash, or another character, such as io.eventsourcingdb.library.book acquired, is refused. A typical cause is a type derived from the name of a class, such as BookAcquired.

When reading or observing events, the type is the one of fromLatestEvent, which the details name as option.

How to Fix It#

Send the event type as a reverse domain name, such as io.eventsourcingdb.library.book-acquired. If you derive types from the names of classes, put a namespace in front of them and use only the characters that a type allows. Sending the same request again fails the same way, since the error depends on the request alone.

Example#

For a write whose first event has the type BookAcquired, 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-type-malformed",
    "description": "event type is malformed: expected a reverse domain name such as 'io.eventsourcingdb.library.book-acquired'",
    "details": {
      "event": 0,
      "value": "BookAcquired"
    }
  }
}