Files
e2e/docs/reference/errors.mdx
T
Oskar Kwaśniewski aadcb5dddb feat(run)!: video modes on the config, targets, the CLI, and tests, with provider recordings (#610)
* feat(run)!: video modes on the config, targets, the CLI, and tests, with step captions

video: off | on | retain-on-failure | on-first-retry at the config root, per
target, --video [mode], and per test or describe, innermost winning.
artifacts.kinds: ['video'] and artifacts.video are removed. Kept recordings
get WebVTT step captions; a video can be a link to a hosted recording. The
engine contract's VideoSegment is a file or a link, and e2e/engine exports
the provider recording seam.

* feat(web): a browser provider records the attempts it serves, and the screencast takes a size and quality

BrowserProvider.record starts the service's own recording of the browser in
place of the page screencast. The session drives one AttemptVideo, the
screencast or the provider's. web({ video: { size, quality } }) tunes the
screencast.

* feat(mobile): a device provider records the attempts it serves

DeviceProvider.record starts the service's own recording of the leased
device in place of agent-device's. The worker learns its slot's lease id,
so record gets the lease as it traveled.

* feat(integrations): Kernel replays record the attempts that record video

* fix(run): captions never fail a video, provider values are normalized, and one list of modes

- Step captions create their directory and are best-effort.
- A provider's recording is checked at start in both engines and its URL
  and start time are stored in the shapes the report schema admits; the
  list reporter bounds a hosted URL.
- --video no longer hides an invalid target mode.
- A describe inside a serial group cannot set video.
- A mobile provider may keep its own leaseId field on a lease.

* fix(mobile): keep the lease type narrowed when checking its declared fields

* fix(run): MCP recordings get their step captions, a step spanning a restart is captioned in both recordings, and video.size refuses unknown keys

* fix: address review on the video API

- One stop in flight per provider recording, shared by a retry; mobile
  dispose stops it, and a cancelled operation never starts one.
- Kernel retries a failed download without stopping the replay twice.
- Links from any engine are held to an http(s) URL with a host; a file a
  provider names must be a regular file; media types are trimmed.
- web({ video }) takes a plain object only; the markdown page labels a
  hosted artifact by its kind.
- Tests: fixture byte totals, captions linked by id, temp directories
  removed, signals asserted, empty sizes, non-object options.
- Docs: engine support qualified, the explore row, the standalone preflight,
  caption status text, a checked stop in the provider example.

* fix(run): a bad engine video link costs no other recording, captions path per recording in debugging guide

* test: fake engine video links doc matches segment order

* fix(mcp): session recordings follow video modes and list a provider's link

* test(web): provider test's fake page reports its viewport

* refactor(run): drop step captions from the video API, tracked in #636

* fix(web): a late provider start never replaces a newer recording, abandon keeps a failed stop's handle, video.size must be a plain object; provider recording errors and hosted URLs bounded
2026-09-29 15:24:26 +02:00

141 lines
17 KiB
Plaintext

---
title: Errors
description: Every code you can see, its class, and its exit code.
---
Every error carries a class. The class determines the exit code; the code
identifies the cause. A model never selects either.
| Class | Exit code |
| --- | ---: |
| test | 1 |
| configuration | 2 |
| infrastructure | 3 |
| internal | 4 |
| interrupted | 130 |
## AgentError
```ts
/** Runner-classified agent failure. */
export class AgentError extends Error {
/** Closed union, assigned by the runner, never taken from model text. */
readonly code: AgentErrorCode;
/** Sanitized, bounded prose; the same value as `message`. */
readonly explanation: string;
/** Artifact path, present only when evidence was captured and permitted. */
readonly screenshot?: string;
/** True when this failure reports a blocked step, not a product failure. */
readonly blocked: boolean;
}
```
Test files load in their own module realm, so `instanceof AgentError` can be
false. Use `isAgentError` from `e2e` and branch on `code`:
```ts
import { isAgentError } from 'e2e';
try {
await agent.act('upgrade the workspace to Pro');
} catch (error) {
if (isAgentError(error) && error.code === 'STEP_TIMEOUT') {
// the step ran out of time; the message carries the last judgment
}
throw error;
}
```
| Code | When it happens | Class | Exit |
| --- | --- | --- | ---: |
| `AUTH_CREDENTIAL_UNAVAILABLE` | A `Secret` or `credentials.user()` names a credential absent from `config.credentials`, the call happened outside an active runner, or the password's provider returned something other than a string of at least 6 characters (code points) | configuration | 2 |
| `AUTH_CREDENTIAL_INVALID` | A configured credential was rejected by the application (blocked: credentials) | configuration | 2 |
| `SECRET_UNAVAILABLE` | A `Secret` or `secrets.get()` names a secret absent from `config.secrets`, the call happened outside an active runner, or the secret's provider returned something other than a string of at least 6 characters (code points) | configuration | 2 |
| `ENVIRONMENT_UNAVAILABLE` | The environment under test is down or unreachable beyond the app itself (blocked: environment) | infrastructure | 3 |
| `SEED_DATA_MISSING` | Data the step depends on does not exist in the environment (blocked: seed_data) | configuration | 2 |
| `TEST_SETUP_FAILED` | Test prerequisites outside the product failed to arrange (blocked: test_setup). Also a `test.extend()` fixture that broke its contract: returned without calling `use()`, called it twice, or redefined a fixture the target's engine contributes | configuration | 2 |
| `AUTOMATION_UNSUPPORTED` | The step needs an interaction the available toolset cannot perform, e.g. drag-and-drop (blocked: automation) | test | 1 |
| `MODEL_UNAVAILABLE` | No model configured: neither `createAgent({ model })` nor `agents.<name>.model` holds an AI SDK model instance. Checked once per run when the `agent` fixture is first acquired; recorded as one run-level error that stops the run. | configuration | 2 |
| `POLICY_DENIED` | A denied destination (`file:`, `data:`, `javascript:`, a malformed URL), a forbidden fill (an undeclared secret, a non-editable sink, a password into a field that is not a password field), or pixel evidence after a secret fill (`vision: 'only'` with pixels withheld). Also reading a value, text, or attribute from a secure field, the getters and the `toHaveValue`, `toHaveText`, `toContainText`, and `toHaveAttribute` matchers alike. An unknown tool or an undeclared field is refused to the model as the call's result and is not this code | configuration | 2 |
| `APP_UNREACHABLE` | The app URL could not be reached, or an app command or service exited early or exceeded `startupTimeout`. Startup errors include recent log output with `command.env` values redacted. If no log is configured, the message suggests adding one. Under the agent, also any engine fault with no more specific code: on a device, an iOS automation runner that is busy or wedged reports here with a message that names the runner, the session and device, and the recovery; see [Testing iOS and Android](/mobile#troubleshooting) | infrastructure | 3 |
| `APP_ALREADY_RUNNING` | `readyUrl` already answered before the engine's `command` (or a `readyUrl` service) was spawned and `reuseExisting` was not in effect; stop that process or set `reuseExisting: true` locally | infrastructure | 3 |
| `MODEL_PROVIDER_FAILED` | Provider transport failure (network error, 5xx, rate limit) after the adapter's transport retries (up to 5 per model call, honoring `retry-after`, bounded by the remaining step timeout) | infrastructure | 3 |
| `CANCELLED` | The runner cancelled the operation, without a process signal | infrastructure | 3 |
| `MODEL_OUTPUT_INVALID` | Structured output still failed validation after the repair budget was spent | test | 1 |
| `APP_NOT_OPEN` | An operation needed an open app; `app.open()` had not run, or the engine reported invalid state | test | 1 |
| `LOCATOR_NOT_FOUND` | No matching node within the deadline, or an agent action refers to a node that is no longer available | test | 1 |
| `LOCATOR_AMBIGUOUS` | More than one match for a single-node operation. Fails immediately, no polling. | test | 1 |
| `ACTION_FAILED` | Actionability failure, operation timeout, or an action that may already have committed | test | 1 |
| `STEP_BUDGET_EXHAUSTED` | The model-call or action-step budget ran out before a conclusion | test | 1 |
| `STEP_TIMEOUT` | The invocation deadline expired, an operation timing out within a poll tick of it included. Carries the last judgment where one exists, with the `ASSERTION_INCONCLUSIVE` vision hint when that judgment was inconclusive | test | 1 |
| `CONTEXT_OVERFLOW` | A request exceeded the model's context window. `act` shortens its history and retries once if that reduces the request; judgments fail directly. Lower `agents.<name>.maxObservationBytes` or split the instruction into shorter steps. Reported as blocked: automation | test | 1 |
| `ASSERTION_FAILED` | `agent.assert` judged false, or a locator, `web`, or value matcher failed | test | 1 |
| `ASSERTION_INCONCLUSIVE` | `agent.assert` could not judge: the screen did not show enough to decide either way (the relevant part is not on screen, still loading, or unreadable). A failure, never a pass; the explanation says what was missing. Judged from the tree alone with `vision` off, the message adds `pass vision: true when the answer is in pixels`, as a condition (`if the engine captures pixels, ...`) until a step of the attempt has received pixels; no hint when the engine declares no screenshot capture, a secret was filled, or an earlier step's pixel request was degraded | test | 1 |
| `AUTHENTICATION_FAILED` | The executor concluded that signing in failed inside the app: a product verdict. `AUTH_CREDENTIAL_INVALID` is the blocked counterpart for a configured credential the app rejects | test | 1 |
| `STEP_NO_CONCLUSION` | The executor used every turn without calling `complete_step`; the step fails with the agent's last summary | test | 1 |
| `REPLAY_STALE` | Under `cache.strict` or `--strict-cache`, the step's recording exists but no longer replays (`step.cache.reason` is one of `invalid-entry`, `wrong-context`, `target-not-found`, `target-ambiguous`, `viewport-changed`, `action-failed`, `action-uncertain`, `end-mismatch`), so the step fails with no model call instead of handing off to the agent. Not retried: a retry never replays and would pass live. Re-record with a read-write run without the flag and commit the changed entry | configuration | 2 |
## Runner codes
These appear in terminal output and in the report as plain string codes.
| Code | When it happens | Class | Exit |
| --- | --- | --- | ---: |
| `CONFIG_NOT_FOUND` | `--config <path>` names a file that does not exist, or no `e2e.config.ts` or `e2e.config.mts` exists from the working directory up to the repository root | configuration | 2 |
| `CONFIG_AMBIGUOUS` | Both `e2e.config.ts` and `e2e.config.mts` in one directory | configuration | 2 |
| `CONFIG_LOAD_FAILED` | The config module failed to import: a package that is declared but not installed, an undeclared package, a wrong subpath, or a removed export. The message names the fix | configuration | 2 |
| `INVALID_CONFIG` | Unknown key, out-of-range value, invalid enum, missing `targets`, a target key outside `{ name, platform, engine, video }`, a `video` that is not a mode, the removed `artifacts.video` block or `video` artifact kind (the message names the `video` option), an `engine` that is not a `defineEngine` handle, `json` reporter combined with `list`, duplicate or malformed target name, a secret or credential password shorter than 6 characters (code points), oversized `agent.context`, an `expect.poll` `timeout` or `interval` that is not a finite number of milliseconds, or a `tests` value that is not a glob or a list of globs | configuration | 2 |
| `CONFIG_NOT_DETERMINISTIC` | A worker re-resolved the config module and got a different digest than the runner | configuration | 2 |
| `APP_URL_REQUIRED` | A navigation or relative URL on a target whose engine declares no `url`, or a declared `command` with no `url` or `readyUrl` to poll | configuration | 2 |
| `INVALID_APP_URL` | Base URL with userinfo, a query, a fragment, a non-HTTP scheme, plain HTTP on a non-loopback host, port 0 on a host other than a literal loopback address (`127.0.0.1`, `[::1]`), a loopback address the run could not bind a free port on, or unparseable | configuration | 2 |
| `INVALID_GLOB` | Empty pattern, a leading `!` exclusion, braces, character classes, extglobs, a backslash separator, an absolute path, a `..` segment, a trailing `/` or `.`, a pattern that names only the project root, or a `**` that is not a whole segment | configuration | 2 |
| `UNKNOWN_TARGET` | `--target` named an ID that is not configured | configuration | 2 |
| `TARGET_REQUIRED` | `e2e mcp`: the config declares several targets and neither `--target` nor `open_session` named one | configuration | 2 |
| `NO_SESSION` | `e2e mcp`: `call`, `tools`, or `close_session` before `open_session` or after the session ended (the message names why), or naming a `session` id that is not the open one | configuration | 2 |
| `SESSION_OPEN` | `e2e mcp`: `open_session` while a session is already open; use it or `close_session` first | configuration | 2 |
| `UNKNOWN_TOPIC` | `e2e mcp`: an `e2e://guide/{topic}` resource named a topic the skill does not have; the message lists them | configuration | 2 |
| `UNKNOWN_TOOL` | `e2e mcp`: `call` or `tools` named a tool the session's catalog does not have; the message lists the catalog | configuration | 2 |
| `UNSUPPORTED_ARTIFACT` | A configured artifact kind (`screenshot`, `trace`) the target's engine cannot produce, or a video that would record on a target whose engine cannot record video: a test that will run and whose [video mode](/reference/config#video) records on some attempt (the message names the target and the test), or an `e2e mcp` session whose target's mode records | configuration | 2 |
| `UNSUPPORTED_CAPABILITY` | A fixture, action, or tier the target's engine does not declare: a contributed fixture it does not contribute, `screen` without `locate`, state restore without `state`, screenshots without `artifacts` | configuration | 2 |
| `NO_TESTS` | Zero runnable ordinary test-target pairs. The message names the cause: no file matched the `tests` globs (with look-alike files), a positional matched nothing, a file registered no tests, or filters excluded everything. Suppress with `--pass-with-no-tests`. | configuration | 2 |
| `NO_LAST_RUN` | `--last-failed` found no `report.json` where the run writes it, or a file there that is not a `report-1` document. Run once without the flag first. | configuration | 2 |
| `ONLY_IN_CI` | A focused test reached a CI run | configuration | 2 |
| `COLLECTION_ERROR` | Registration outside collection, an invalid title, a non-function body, an async `describe` body, nested serial groups, an option forbidden inside a serial group, a setup test inside `describe`, an invalid session name, a malformed test option such as `tags` that is not a list of distinct names, a test file that fails to import (in a run with no positionals, or a file the positionals selected), a session a selected test consumes that no collected setup test produces, or a positional path outside the project root | configuration | 2 |
| `POLICY_DENIED` | A denied destination (`file:`, `data:`, `javascript:`, a malformed URL), a forbidden fill (an undeclared secret, a non-editable sink, a mismatched purpose, a `Secret` reaching a JSON sink), or tainted pixels (`app.screenshot()` after a secret fill, `vision: 'only'` with pixels withheld); see the [security model](/security). An unknown tool or an undeclared field goes back to the model as the call's result, never this code | configuration | 2 |
| `SESSION_MISMATCH` | A stored session does not match the current run, target, engine, platform, or app identity | configuration | 2 |
| `SESSION_EXPIRED` | A stored session is past its expiry at restore time (configuration, exit 2), or a setup test saved state whose expiry is not after its creation (test, exit 1) | configuration or test | 2 or 1 |
| `SESSION_INVALID` | A stored session failed authentication. Tampered or corrupt. | configuration | 2 |
| `SESSION_UNAVAILABLE` | A test requires a session no selected setup test produced | configuration | 2 |
| `SESSION_CONTRACT` | A setup test saved a session twice, saved an undeclared name, or finished without saving a declared one | test | 1 |
| `TEST_TIMEOUT` | The attempt exceeded the resolved test `timeout`. The body is not stopped: the harness operation it is in is cancelled and its fixtures die with the attempt, so it cannot reach the next test | test | 1 |
| `STEP_NOT_AWAITED` | The test body settled while a step it started was still running: a step call without `await`. The step is failed at the line of the call and cancelled; the attempt fails with this code when the body returned, or keeps the body's own error and records this one under `secondaryErrors` when the body threw | test | 1 |
| `UNHANDLED_REJECTION` | A promise rejected with no test running. An unhandled rejection is charged to the test running when it surfaces, since Node cannot say which test created the promise; between tests it is this run error, naming the last test that finished in the worker as the likely source. Before any test has finished in the worker it ends the worker instead: the rejection is the run error and the test on its way fails with `WORKER_CRASH`. The body that left it keeps running like one past `TEST_TIMEOUT` | test | 1 |
| `HOOK_FAILED` | `beforeAll` or `afterAll` threw. Skips the suite's tests. | test | 1 |
| `LAUNCH_TIMEOUT` | Engine init or attempt start exceeded `config.launchTimeout` | infrastructure | 3 |
| `CLEANUP_TIMEOUT` | Engine attempt end exceeded `config.cleanupTimeout`, or a route or dialog handler the engine ran for the test was still running when the attempt settled | infrastructure | 3 |
| `TRACE_WITHHELD` | A trace from an attempt that filled a secret could not be rewritten, so it was deleted. Recorded in the attempt's `secondaryErrors`; never fails the attempt. | infrastructure | 3 |
| `BROWSER_INSTALL_FAILED` | Browser provisioning failed | infrastructure | 3 |
| `WORKER_INIT_FAILED` | A worker process never became ready | infrastructure | 3 |
| `WORKER_EXIT` | A worker exited unexpectedly while running a file: the test in flight fails with `WORKER_CRASH` and the file's other tests are skipped. An unhandled rejection is charged to the test running when it surfaces, or recorded as `UNHANDLED_REJECTION` between tests; before any test has finished there it ends the worker, and the rejection itself is the run error, not this one | infrastructure | 3 |
| `WORKER_CRASH` | A worker exited during a specific test | infrastructure | 3 |
| `WORKER_ENTRY_MISSING` | The worker entry module could not be resolved. Packaging fault. | infrastructure | 3 |
| `ENGINE_FAILURE` | Any engine fault with no more specific mapping | infrastructure | 3 |
| `WORKER_PROTOCOL` | A worker reported a unit other than the one it was running, or started an attempt while another was still running | infrastructure | 3 |
| `SESSION_KEY_INVALID` | A worker received a session key that is not 32 bytes. Packaging or IPC fault. | infrastructure | 3 |
| `REPORT_WRITE_FAILED` | `report.json` or `ai-trace.json` could not be written. Recorded as a run error; the in-memory outcome is still complete. A `junit.xml` that could not be written is the `junit` reporter's stderr line instead | infrastructure | 3 |
| `EVALUATE_FAILED` | `web.evaluate` threw inside the page (`@e2e-dev/web`) | test | 1 |
| `INTERRUPTED` | A user or CI signal aborted the run | interrupted | 130 |
Errors raised by argument validation in test code use `INVALID_ARGUMENT` and
`INVALID_LOCATOR`, both test failures with exit code 1. An unclassified thrown
value from test code is reported as `ERROR`. The `internal` class and exit
code 4 are reserved for runner invariant violations; no first-party code raises
a code in that class today.
## Exit codes
For a mixed run the highest-precedence code present wins, `130 > 4 > 3 > 2 >
1 > 0`. The report keeps every individual result. A setup assertion failure
is a test failure and skips its dependents. Missing setup infrastructure keeps
its configuration or infrastructure class.