# subject-malformed

A **subject** in the request is **not a valid subject**.

- **Routes:** `write-events`, `read-events`, `observe-events`, and `read-subjects`
- **Description:** `subject is malformed: expected a slash-separated path such as '/books/42'`
- **Details:** **`value`**, the subject as the request gave it. When writing events, also **`event`** or **`precondition`**, the place of the event or the precondition in its list, counting from 0. When reading or observing events, also **`option`**, which is `fromLatestEvent` where the subject is the one of that option; without it, the subject is the one to read or observe.

## Why It Happens

A **[subject](/docs/eventsourcingdb/subjects)** is a path that **starts with a slash**, with segments separated by slashes, each made of **letters, digits, underscores, and hyphens** only. A subject without its leading slash, such as `books/42`, or with a space, a dot, or another character, such as `/books/42.json`, is refused.

When reading or observing events, the subject can be the one to read or the one of **`fromLatestEvent`**; the details tell them apart by **`option`**, which only the second has.

## How to Fix It

Send the subject as a slash-separated path, such as `/books/42`. If you build subjects from values such as names or file names, replace the characters that a subject does not allow.

## Example

To read the events of `books/42`, without the leading slash, 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/subject-malformed",
    "description": "subject is malformed: expected a slash-separated path such as '/books/42'",
    "details": {
      "value": "books/42"
    }
  }
}
```
