lobehub/lobehub · error · InvalidArgumentError

Device "${deviceId}" was not found. Check 'lh device list' a

Error message

Device "${deviceId}" was not found. Check 'lh device list' and try again.

What it means

Thrown by `lh eval case execute --device <id>` after the CLI fetches the live device list via `client.device.listDevices.query()` and finds no entry whose `deviceId` matches the resolved `--device` value. It is an `InvalidArgumentError`, so Commander renders it as a bad-argument message rather than a stack trace. The check exists so the eval run cannot be dispatched to a device the server does not know about.

Source

Thrown at apps/cli/src/commands/eval.ts:1071

            let deviceId: string | undefined;
            if (options.device !== undefined) {
              if (options.device === 'local') {
                deviceId = resolveLocalDeviceId();
                if (!deviceId) {
                  throw new InvalidArgumentError(
                    "No local device found. Run 'lh connect' first, then retry with --device local.",
                  );
                }
              } else {
                deviceId = options.device;
              }

              const devices = await client.device.listDevices.query();
              const matched = devices.find(
                (device: { deviceId?: string; online?: boolean }) => device.deviceId === deviceId,
              );
              if (!matched) {
                throw new InvalidArgumentError(
                  `Device "${deviceId}" was not found. Check 'lh device list' and try again.`,
                );
              }
              if (!matched.online) {
                throw new InvalidArgumentError(
                  `Device "${deviceId}" is not online. Bring it online and try again.`,
                );
              }
            }

            return client.agentEvalExternal.runExecuteCase.mutate({
              caseId: options.caseId,
              deviceId,
              prompt: options.prompt,
              runId: options.runId,
            });
          },
          `Started case ${pc.bold(options.caseId)} for run ${pc.bold(options.runId)}`,

View on GitHub (pinned to 10f24d7ade)

Solutions

  1. Run `lh device list` and copy the exact `deviceId` from the current server.
  2. Confirm you are targeting the right server (`--server` / logged-in account) — device lists are per-deployment.
  3. If using `--device local`, re-run `lh connect` to refresh the local device registration, then retry.
  4. Verify the ID has no surrounding whitespace or quotes when passed on the shell.

Example fix

# before
lh eval case execute --case-id c1 --device dev-1234 --run-id r1

# after (copy exact id from `lh device list`)
lh device list
lh eval case execute --case-id c1 --device 01HXY... --run-id r1
Defensive patterns

Strategy: validation

Validate before calling

import { getTrpcClient } from './trpc';

async function assertDeviceExists(deviceId: string) {
  const client = await getTrpcClient();
  const devices = await client.device.listDevices.query();
  const ids = new Set(devices.map((d) => d.deviceId));
  if (!ids.has(deviceId)) {
    throw new Error(`Unknown device ${deviceId}. Known: ${[...ids].join(', ')}`);
  }
  return devices.find((d) => d.deviceId === deviceId)!;
}

// call before dispatching the eval
await assertDeviceExists(deviceId);

Type guard

const isDeviceRef = (v: unknown): v is string =>
  typeof v === 'string' && /^[A-Za-z0-9_.-]{8,}$/.test(v);

Prevention

When it happens

Trigger: Passing `--device <id>` with a typo'd or stale ID; passing an ID from a different LobeHub workspace/account; passing `--device local` after `resolveLocalDeviceId()` returned a cached ID that the server has since deregistered; the device record was deleted between `lh connect` and the eval call.

Common situations: Copy-pasting a device ID from an old terminal session; sharing a script across machines where each machine's `local` device differs; the connected device was removed via `lh device remove` or the server's admin UI; wrong `--server` target so a different device pool is queried.

Related errors


AI-assisted analysis of lobehub/lobehub@10f24d7ade (2026-08-12). Data as JSON: /api/errors/dfeeca6ab30ee2be. Report an issue: GitHub.