# Errors

> HTTP error statuses returned by dvm.run, what each means, and how each SDK surfaces them.

This is the Markdown of https://docs.dvm.run/reference/errors/. Every page of the dvm.run docs is served as Markdown at its address plus `.md`; the list of pages is https://docs.dvm.run/llms.txt.

When dvm.run rejects a request, it returns an HTTP status code and a JSON body with a `message` field explaining why. Each SDK surfaces that text on its error: `ApiError.message` in Python, `ApiError.reason` in TypeScript, and the `reason` of `dvm_run::Error` in Rust. A program’s exit code is never treated as an error.

## Statuses

| Status | Means                                                                                                                                            | Python, TypeScript       | Rust                                 |
| ------ | ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------ | ------------------------------------ |
| `400`  | The request isn’t one dvm.run takes: a bad image name, a value out of range, a sandbox larger than your plan allows, an input chunk over 64 KiB. | `InvalidRequestError`    | `Error::InvalidRequest`              |
| `401`  | No key, or a key that was revoked or isn’t one: `that API key was revoked, or isn't one: send Authorization: Bearer <key>`.                      | `AuthenticationError`    | `Error::Authentication`              |
| `402`  | Your credit doesn’t pay for it: `your credit is used up: what's left pays for less than a minute of this sandbox`.                               | `ApiError`, `status` 402 | `Error::Refused { status: 402, .. }` |
| `403`  | Your account is on the waitlist: `you're on the waitlist: you can use dvm once we let you in`.                                                   | `ApiError`, `status` 403 | `Error::Refused { status: 403, .. }` |
| `404`  | No such sandbox, or not yours (`no sandbox N`); or, at a point of a run, no such file.                                                           | `NotFoundError`          | `Error::NotFound`                    |
| `409`  | What you asked can’t be done in the state it’s in.                                                                                               | `ConflictError`          | `Error::Conflict`                    |

None of the SDKs defines a dedicated class for `402` or `403`; check the status code instead.

## `409` in detail

* **Too many active sandboxes:** `you have N sandboxes going, the most the <plan> plan allows; stop one first`.
* **Too many concurrent seeks:** `too many timeline seeks in progress; try again in a moment`.
* **Session input errors:** `this sandbox runs a program and takes no input`, `the run has not started yet`, `the run already ended`, `input already ended at length N`.
* **Concurrent run modification:** `run N changed meanwhile; reload it and try <action> again`.
* **Sandbox already ended:** `sandbox N has ended`. Instead of a conflict error, the SDKs raise `SandboxEndedError` (`Error::SandboxEnded`), or `SandboxFailedError` (`Error::SandboxFailed`) with the reason when dvm or the platform terminated the sandbox.
* **Inspection errors:** `sandbox N is still running`, `sandbox N was stopped before exit`, `sandbox N failed before exit`, `… ran on an older dvm than its runner's now: run it again`, or the reason a replay failed ([Inspecting a finished run](/guides/inspect/)).

## Inspection statuses

When inspecting a point in a run, an error’s body has, beside `message`, a `file_error` or `stop_error` field that names its kind, such as `{"message": "the sandbox is returning to that point", "stop_error": "returning"}`:

| Status | Means                                                                                                                                    |
| ------ | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `400`  | The path isn’t absolute, isn’t a directory for a list, or isn’t a regular file for a read.                                               |
| `404`  | No such file there.                                                                                                                      |
| `409`  | `the sandbox isn't held at that point`. The routes seek there again first, so you see this only when that didn’t hold either: ask again. |
| `422`  | The bytes aren’t in the recording (`the sandbox never read the bytes from there`), or a number in the answer would reach 253.            |
| `500`  | dvm couldn’t read the file.                                                                                                              |
| `501`  | `dvm doesn't serve this mount's files yet`.                                                                                              |
| `503`  | `the sandbox is returning to that point`: it wasn’t there yet when the call’s wait ran out. The SDKs ask again, up to four times.        |

## Other errors the SDKs raise

|                                                                                 | Python               | TypeScript           | Rust                    |
| ------------------------------------------------------------------------------- | -------------------- | -------------------- | ----------------------- |
| Every error                                                                     | `DvmError`           | `DvmError`           | `dvm_run::Error`        |
| dvm.run out of reach, or the connection dropped                                 | `NetworkError`       | `NetworkError`       | `Error::Network`        |
| Another status                                                                  | `ApiError`           | `ApiError`           | `Error::Refused`        |
| The sandbox ended first                                                         | `SandboxEndedError`  | `SandboxEndedError`  | `Error::SandboxEnded`   |
| dvm or the platform ended it                                                    | `SandboxFailedError` | `SandboxFailedError` | `Error::SandboxFailed`  |
| The session’s server refused a request, such as reading a file that isn’t there | `DvmError`           | `DvmError`           | `Error::SandboxRequest` |
| A command sent to a sandbox running its own program                             | `DvmError`           | `DvmError`           | `Error::Conflict`       |
| No key found                                                                    | `DvmError`           | `DvmError`           | `Error::NoApiKey`       |
| A credentials file that isn’t what `dvm-run login` writes                       | `DvmError`           | `DvmError`           | `Error::Credentials`    |

## Retries

The SDKs retry after 0.1, 0.25, 0.5, and 1 second on `408` and `429`, and on `502`, `503`, and `504` for requests that are safe to repeat. A `Retry-After` header is honored up to 5 seconds. They wait up to 60 seconds for a response.
