# source-malformed

The **[source](/docs/eventsourcingdb/sources)** of an event is **not a URI** as RFC 3986 defines it.

- **Route:** `write-events`
- **Description:** `source is malformed: expected a URI as defined by RFC 3986, such as 'https://library.eventsourcingdb.io'`
- **Details:** **`event`**, the place of the event in its list, counting from 0, and **`value`**, the source as the request gave it.

## Why It Happens

A source has to be a **URI with a scheme**, such as `https:` or `tag:`, made only of the characters that **[RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986)** allows in each of its parts. A **relative reference** such as `/library`, which CloudEvents allows, and a bare host name such as `library.eventsourcingdb.io` have no scheme and are refused, and so is a source with a **character that is not percent-encoded**, such as a space or `ä`.

## How to Fix It

Send the source as a URI, such as `https://library.eventsourcingdb.io` or `tag:eventsourcingdb.io,2025:library`, and percent-encode the characters that a URI does not allow, for example a space as `%20`. 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 source `library.eventsourcingdb.io`, without a scheme, 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/source-malformed",
    "description": "source is malformed: expected a URI as defined by RFC 3986, such as 'https://library.eventsourcingdb.io'",
    "details": {
      "event": 0,
      "value": "library.eventsourcingdb.io"
    }
  }
}
```
