# precondition-type-missing

A **[precondition](/docs/eventsourcingdb/preconditions)** leaves out its **type**.

- **Route:** `write-events`
- **Description:** `precondition type is missing: expected 'isSubjectPristine', 'isSubjectPopulated', 'isSubjectOnEventId', or 'isEventQlQueryTrue'`
- **Details:** **`precondition`**, the place of the precondition in its list, counting from 0.

## Why It Happens

Every precondition names its **`type`**, which says what it checks and which values its `payload` holds. A precondition **without a type**, or with an **empty string** as its type, cannot be checked, such as one that was built from its payload alone, as in `{ "payload": { "subject": "/books/42" } }`.

The preconditions are checked after the events of the write, one after the other, so the error names the first that leaves out its type. A type that is given but does not exist is reported as **[`precondition-unknown`](/docs/eventsourcingdb/errors/precondition-unknown)** instead, and a type that is `null` is rejected with `400 Bad Request`, since the body then does not have the shape the route expects.

## How to Fix It

Give every precondition one of the **[four types](/docs/eventsourcingdb/preconditions#available-precondition-types)**: `isSubjectPristine`, `isSubjectPopulated`, `isSubjectOnEventId`, or `isEventQlQueryTrue`. Sending the same request again fails the same way, since the error depends on the request alone.

## Example

For a write whose only precondition leaves out its type, EventSourcingDB answers with this error, as a line of the stream, and then ends the stream with its `end` item:

```json
{
  "type": "error",
  "data": {
    "code": "https://docs.eventsourcingdb.io/errors/precondition-type-missing",
    "description": "precondition type is missing: expected 'isSubjectPristine', 'isSubjectPopulated', 'isSubjectOnEventId', or 'isEventQlQueryTrue'",
    "details": {
      "precondition": 0
    }
  }
}
```
