{"record":{"id":"dfeeca6ab30ee2be","repo":"lobehub/lobehub","slug":"device-deviceid-was-not-found-check-lh-devi","errorCode":null,"errorMessage":"Device \"${deviceId}\" was not found. Check 'lh device list' and try again.","messagePattern":"Device \"(.+?)\" was not found\\. Check 'lh device list' and try again\\.","errorType":"validation","errorClass":"InvalidArgumentError","httpStatus":null,"severity":"error","filePath":"apps/cli/src/commands/eval.ts","lineNumber":1071,"sourceCode":"            let deviceId: string | undefined;\n            if (options.device !== undefined) {\n              if (options.device === 'local') {\n                deviceId = resolveLocalDeviceId();\n                if (!deviceId) {\n                  throw new InvalidArgumentError(\n                    \"No local device found. Run 'lh connect' first, then retry with --device local.\",\n                  );\n                }\n              } else {\n                deviceId = options.device;\n              }\n\n              const devices = await client.device.listDevices.query();\n              const matched = devices.find(\n                (device: { deviceId?: string; online?: boolean }) => device.deviceId === deviceId,\n              );\n              if (!matched) {\n                throw new InvalidArgumentError(\n                  `Device \"${deviceId}\" was not found. Check 'lh device list' and try again.`,\n                );\n              }\n              if (!matched.online) {\n                throw new InvalidArgumentError(\n                  `Device \"${deviceId}\" is not online. Bring it online and try again.`,\n                );\n              }\n            }\n\n            return client.agentEvalExternal.runExecuteCase.mutate({\n              caseId: options.caseId,\n              deviceId,\n              prompt: options.prompt,\n              runId: options.runId,\n            });\n          },\n          `Started case ${pc.bold(options.caseId)} for run ${pc.bold(options.runId)}`,","sourceCodeStart":1053,"sourceCodeEnd":1089,"githubUrl":"https://github.com/lobehub/lobehub/blob/10f24d7ade75139093a9373b364f6bc91f3cd7db/apps/cli/src/commands/eval.ts#L1053-L1089","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run `lh device list` and copy the exact `deviceId` from the current server.","Confirm you are targeting the right server (`--server` / logged-in account) — device lists are per-deployment.","If using `--device local`, re-run `lh connect` to refresh the local device registration, then retry.","Verify the ID has no surrounding whitespace or quotes when passed on the shell."],"exampleFix":"# before\nlh eval case execute --case-id c1 --device dev-1234 --run-id r1\n\n# after (copy exact id from `lh device list`)\nlh device list\nlh eval case execute --case-id c1 --device 01HXY... --run-id r1","handlingStrategy":"validation","validationCode":"import { getTrpcClient } from './trpc';\n\nasync function assertDeviceExists(deviceId: string) {\n  const client = await getTrpcClient();\n  const devices = await client.device.listDevices.query();\n  const ids = new Set(devices.map((d) => d.deviceId));\n  if (!ids.has(deviceId)) {\n    throw new Error(`Unknown device ${deviceId}. Known: ${[...ids].join(', ')}`);\n  }\n  return devices.find((d) => d.deviceId === deviceId)!;\n}\n\n// call before dispatching the eval\nawait assertDeviceExists(deviceId);","typeGuard":"const isDeviceRef = (v: unknown): v is string =>\n  typeof v === 'string' && /^[A-Za-z0-9_.-]{8,}$/.test(v);","tryCatchPattern":null,"preventionTips":["Always resolve `--device local` via `resolveLocalDeviceId()` and surface a clear error before fetching the device list.","Cache the device list for only a few seconds; device identity changes.","In CI, assert the device is registered right after `lh connect` rather than assuming it.","Print `lh device list` output in your script's failure log when an eval aborts."],"tags":["cli","eval","device","invalid-argument"],"backgroundTag":null,"analyzedSha":"10f24d7ade75139093a9373b364f6bc91f3cd7db","analyzedAt":"2026-08-12T11:43:19.543Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}