<!-- KeepSnappy docs for keepsnappy CLI 0.1.0-alpha.35 -->

# Troubleshooting

> Setup and run errors with their fixes, and what to do when init stops or leaves something to you.

This page is for anyone setting up or running KeepSnappy who meets an error. Find the line your log or init printed, and its fix is beside it. If yours is not here, ask whoever set KeepSnappy up on your team, or the person who invited you.

## Fix common problems

Each line starts with what the log says.

- `--upload needs the project key in the environment variable KEEPSNAPPY_KEY`: the secret does not reach the step. Add the `env:` block with `KEEPSNAPPY_KEY` to the step that runs `keepsnappy`.
- `cannot open a run set at …: invalid_key (check KEEPSNAPPY_KEY)`: the API refused the key with `invalid_key`. The key in `KEEPSNAPPY_KEY` is wrong, or it no longer works. Make a new CI key on **Setup**, step 1, and store it as the GitHub secret `KEEPSNAPPY_KEY`.
- `cannot open a run set at …: CI key was revoked. Ask an organisation owner or admin for a new CI key and update the CI secret. (check KEEPSNAPPY_KEY)`: someone stopped this CI key. Ask an owner or admin of your organization for a new one, and store it as the GitHub secret `KEEPSNAPPY_KEY`.
- `Session failed: no run sent any data. Check that the build carries the SDK and that the app reaches the API.`: the app was built without `KEEPSNAPPY=1` or with `measureFromLaunch` off ([plugin options](https://keepsnappy.com/docs/sdk.md#plugin-options)), or it is not installed on the booted simulator. Set `KEEPSNAPPY=1` for `prebuild` and the build.
- `Session failed — no iteration sent any data` (the `farm` command says iteration for a run), or a run whose app had sending switched off: the build has no [SDK key](https://keepsnappy.com/docs/glossary.md#sdk-key) or no API address. A build whose app sends its own measurements needs both ([which builds do](https://keepsnappy.com/docs/sdk.md#the-build-switch)). Copy both from **Setup**, step 1, under **Builds that send their own measurements**. Set them as `EXPO_PUBLIC_KEEPSNAPPY_KEY` and `EXPO_PUBLIC_KEEPSNAPPY_INGEST_URL` in the build environment, and build again. The CI key does not replace the SDK key.
- `Can’t tell — the device session failed`, on [BrowserStack](https://keepsnappy.com/docs/browserstack.md): BrowserStack ended the device session before any run sent data. Open the session from the `Device session:` line to see why, then run the job again. The step fails with exit `1`, even with `verdict_gate: advisory`.
- `Session failed: no run sent any data. Every run failed its test command`: your tests failed. Read `test.log` in each run folder of `keepsnappy-out`. With Maestro, `test.log` holds only its summary: the screenshots and view hierarchy of the failing step are in the debug folder it names (under `~/.maestro/tests/`).
- Runs the log lists as `test-failed`: that journey’s test failed. Read its `test.log` first, whatever the **Session failed** line says.
- Runs the log lists as `no-windows`: the SDK recorded no measurement windows during the run. Check that the measuring build is active on the selected device and that the journey reaches a screen or taps while KeepSnappy records, from the run's start to its end.
- **Can’t tell**, “too few places could be judged”, with places that read “the component data at this place is incomplete”, or **Can’t tell**, “the judged measures are missing in one session” on a result judged with earlier rules: the build may have no render times: `renderTimes` is off in the plugin options. Turn it on, then run `prebuild` and the build again.
- **Can’t tell**, “main does not have enough sessions on this phone and journey yet”: run the workflow on `main` until it has 3 sessions on the same [phone model](https://keepsnappy.com/docs/glossary.md#phone-model).
- HTTP 429 with error code `rate_limited`: you sent too many requests to the API. Wait for the time in `Retry-After`, then try again.
- `run_token_exhausted`: one run sent more data than its [run token](https://keepsnappy.com/docs/ci.md#builds-that-send-their-own-measurements) allows. Run the job again. If it happens again, ask the person who invited you.

When you report an API error, include its `request_id`.

## If init stops or leaves something to you

<span id="what-init-does-in-other-cases"></span>Each line starts with what init prints.

- `Cannot go on: The iOS bundle id is not in app.json or the Xcode project.`: your app config builds the bundle id in code. Run init again with `--bundle-id` and the bundle id of the Release build you measure. The `bundle-id` line of [`doctor`](https://keepsnappy.com/docs/reference/cli.md#doctor) reads `MISS` until `npx expo prebuild` writes the `ios/` folder. Until then, ignore that `MISS`. Doctor exits 1 for it, also with `--local`.
- `No changes made.`: init could not ask its questions, for example in a script, in CI or in a coding agent. Run it again with `--yes`, then store the CI key with `npx --no-install keepsnappy init --key`.
- `By you:` and a line to add: init does not edit `app.config.js` or `app.config.ts`. Add `'@keepsnappy/react-native'` to the `plugins` array returned by that config, keeping the entries it already returns.
- `init does not set up Detox`: write `keepsnappy.yml` by hand, with your Detox command as [the `command` setting](https://keepsnappy.com/docs/glossary.md#the-command-setting) ([Any other test command](https://keepsnappy.com/docs/journeys.md#any-other-test-command)).

- `By you: Wrap the final config in metro.config.mjs:` (or your config's filename). Wrap the exported config with `withKeepSnappy`, imported from `@keepsnappy/react-native/metro.js`. Pass it the final config after your existing resolver, transformer and other wrappers have been applied ([Install by hand](https://keepsnappy.com/docs/install.md#two-config-changes)).
- `By you: Make a CI job that checks out the pull request's head with its whole history (fetch-depth: 0)`: init found no workflow job it could copy. Follow the printed steps or copy the CI example from your test tool's page: [Maestro](https://keepsnappy.com/docs/test-tools/maestro.md#ci-example), [Appium](https://keepsnappy.com/docs/test-tools/appium.md#ci-example) or [e2e](https://keepsnappy.com/docs/test-tools/e2e.md#ci-example). For a local device or a device farm, [choose your setup](https://keepsnappy.com/docs/index.md#choose-your-setup) to find the build and run steps for that environment.

Init exits 0 once its changes are made, and lists what is left under `Next steps`. It exits 1 only when it cannot go on, an install fails, or `--key` cannot store the key. Running it twice changes nothing.

Setting up by hand: [Install by hand](https://keepsnappy.com/docs/install.md#install-and-build-by-hand). Without Expo's `prebuild`: [Bare React Native](https://keepsnappy.com/docs/bare-react-native.md).

### Doctor checks the upstream repository instead of your fork

If the `key` warning names a repository whose secrets you cannot list, check the repository `gh repo view` selects from this checkout. For a fork, set `GH_REPO` to your fork's `OWNER/REPO` when you run doctor or `keepsnappy init --key`. Check the repository name before setting the key. If doctor names the right repository and still cannot list its secrets, ask a repository admin to check the CI secret.

## A default branch other than main

KeepSnappy compares each pull request with one branch of your repository. For your app that branch is `main`, unless it was set to another. There is no dashboard setting for it yet, and the `keepsnappy` command cannot change it.

Init's workflow runs on pushes to your repository's default branch, for example `develop`. If that branch is not your app's comparison branch, its sessions never count as `main`. Every pull request then reads **No main to compare**.

To check it, put the CI key in your shell and run `npx --no-install keepsnappy doctor --group app`. Its `comparison-branch` line reads `FAIL` when your workflow runs on a branch KeepSnappy does not compare with.

If your default branch is not `main`:

1. Ask the person who invited you to have KeepSnappy compare with your branch.
2. Read `main` on these pages as your branch. Run the workflow with `gh workflow run keepsnappy.yml --ref develop`, and a session on your Mac with `npx --no-install keepsnappy run --upload --wait --branch develop` ([Try it on your Mac](https://keepsnappy.com/docs/on-your-mac.md#measure-a-session-before-ci)).

## Result still pending after the CLI stops waiting

If the CLI times out waiting for the result, open the dashboard link in its output. The session can still receive a result after the command exits. For a job that should wait longer, set `--wait-timeout` in minutes and leave enough time for it in the CI job. See [Run exit codes](https://keepsnappy.com/docs/reference/cli.md#run).

## Maestro

Each line starts with what you see. [Maestro](https://keepsnappy.com/docs/test-tools/maestro.md) has the setup.

- The run stops and lists several simulators: more than one is booted and none is named. Set `device` to the UDID, or pass `--device`.
- A flow reads an empty value that your shell has set: Maestro forwards only `MAESTRO_*` variables. Set the value under that name.
- A renamed flow shows no history: a new file name is a new journey. Give `main` 3 sessions with the new name.
- A flow that waits for an element fails on a slow runner: raise that wait's `timeout`. Do not add a fixed pause.

## Appium

Each line starts with what you see. [Appium](https://keepsnappy.com/docs/test-tools/appium.md) has the setup.

- Runs listed as `no-windows`: the SDK recorded no measurement windows. Check that Appium drives the measuring build on the simulator named in `device`, and that it reaches a screen or taps while KeepSnappy records.
- `Session failed: no run sent any data. Check that the build carries the SDK and that the app reaches the API.`: the app under test is not the [measuring build](https://keepsnappy.com/docs/glossary.md#measuring-build), or Appium installed another build over it. Build with `KEEPSNAPPY=1` and install that build once.
- Every run starts with a slow session or times out: the first Appium session on a fresh runner needs time to start. Raise `timeout_seconds`.
- The activation link arrives but the SDK sends nothing: if the measuring build waits for activation, check that the Appium journey module starts the app after the link. If you pinned `@keepsnappy/appium-driver`, check it against [Versions that work together](https://keepsnappy.com/docs/install.md#versions-that-work-together). An older driver can deliver the link without relaunching the app.
- The suite drives another simulator than the one KeepSnappy reads: give both the same UDID, and boot only one simulator.
- A run is slow or odd after a failed attempt passed on a retry: KeepSnappy does not detect Appium retries. Set `specFileRetries` and the retries of your test framework to 0.

## e2e

<span id="testerarmy"></span>e2e (formerly TesterArmy e2e): each line starts with what you see. [e2e](https://keepsnappy.com/docs/test-tools/e2e.md) has the setup.

- Runs refused with `e2e-ai-step` or `e2e-model-event`: a test used AI. The dashboard and the log name the step. Move the test under your `ai` tag, or to a job KeepSnappy does not wrap.
- Runs refused with `e2e-retry`: e2e retried a test. Turn its retries off with the `--retries` option, as in the command on the [e2e](https://keepsnappy.com/docs/test-tools/e2e.md#settings-in-keepsnappyyml) page.
- Runs refused with `e2e-report-missing`: e2e wrote no new `report.json`. Check that the command ran the tests, and that KeepSnappy reads the right path: set `flows.e2e_report` when a script runs e2e. KeepSnappy prints the path it read.
- Runs refused with `e2e-report-schema`: the report is in a format this CLI does not read. Use the `e2e` version that the [e2e page](https://keepsnappy.com/docs/test-tools/e2e.md#install) names, or a newer CLI.
- Exploration (`explore`) stops the run before it starts: exploration is AI only and is never wrapped.
- The first run is slow or times out: e2e builds its iOS runner on first use. Keep the unmeasured call before `keepsnappy run`, and raise `timeout_seconds`.

All KeepSnappy docs for agents: https://keepsnappy.com/llms.txt
