# precondition-unknown

A **[precondition](/docs/eventsourcingdb/preconditions)** has a **type that does not exist**.

- **Route:** `write-events`
- **Description:** `precondition type is unknown: expected 'isSubjectPristine', 'isSubjectPopulated', 'isSubjectOnEventId', or 'isEventQlQueryTrue'`
- **Details:** **`precondition`**, the place of the precondition in its list, counting from 0, and **`value`**, the type as the request gave it.

## Why It Happens

EventSourcingDB knows four types of preconditions: `isSubjectPristine`, `isSubjectPopulated`, `isSubjectOnEventId`, and `isEventQlQueryTrue`, and refuses any other. The types are **case-sensitive**, so a typo such as `isSubjectOnEventID`, with a capital `D`, is enough.

Since a type that does not exist says nothing about its payload, **the payload is not checked**: a mistake in it shows only once the type is right. **The fields of the precondition itself are checked**, though, since every precondition has the same two, `type` and `payload`: a further field, such as `note`, and one that spells either of them otherwise, such as `TYPE`, are rejected with `400 Bad Request` as unknown fields, whatever the type, as in `/preconditions/0/TYPE: unknown field`. A precondition that leaves out its type is reported as **[`precondition-type-missing`](/docs/eventsourcingdb/errors/precondition-type-missing)** instead.

## How to Fix It

Correct the type that **`value`** shows to one of the **[four types](/docs/eventsourcingdb/preconditions#available-precondition-types)**, spelled exactly as they are. Sending the same request again fails the same way, since the error depends on the request alone.

## Example

For a write whose second precondition has the type `isSubjectOnEventID`, 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-unknown",
    "description": "precondition type is unknown: expected 'isSubjectPristine', 'isSubjectPopulated', 'isSubjectOnEventId', or 'isEventQlQueryTrue'",
    "details": {
      "precondition": 1,
      "value": "isSubjectOnEventID"
    }
  }
}
```
