{"record":{"id":"80be70dea0bbc4a5","repo":"stablyai/orca","slug":"invalid-argument-80be70","errorCode":"invalid_argument","errorMessage":"--${name} must be between 0 and 1","messagePattern":"--(.+?) must be between 0 and 1","errorType":"exception","errorClass":"RuntimeClientError","httpStatus":null,"severity":"error","filePath":"src/cli/handlers/emulator.ts","lineNumber":59,"sourceCode":"  state?: string\n}\n\nfunction formatEmulatorDevices(value: unknown): string {\n  const devices = Array.isArray(value) ? (value as EmulatorDeviceRow[]) : []\n  if (devices.length === 0) {\n    return 'No emulator devices found.'\n  }\n  return devices\n    .map((device) => {\n      const platform = device.backend === 'android' ? 'Android' : 'iOS'\n      return `${platform.padEnd(8)} ${(device.state ?? '').padEnd(9)} ${device.name ?? ''}  (${device.id ?? ''})`\n    })\n    .join('\\n')\n}\n\nfunction assertNormalizedCoordinate(value: number, name: string): void {\n  if (value < 0 || value > 1) {\n    throw new RuntimeClientError('invalid_argument', `--${name} must be between 0 and 1`)\n  }\n}\n\nfunction parseEmulatorGesturePoints(raw: string): EmulatorGesturePoint[] {\n  let parsed: unknown\n  try {\n    parsed = JSON.parse(raw)\n  } catch {\n    throw new RuntimeClientError('invalid_argument', '--points must be valid JSON')\n  }\n  const value =\n    parsed && typeof parsed === 'object' && 'points' in parsed\n      ? (parsed as { points?: unknown }).points\n      : parsed\n  if (!Array.isArray(value) || value.length < 2 || value.length > 64) {\n    throw new RuntimeClientError(\n      'invalid_argument',\n      '--points must be an array of 2 to 64 touch points'","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/cli/handlers/emulator.ts#L41-L77","documentation":"Thrown by assertNormalizedCoordinate in emulator.ts when an emulator gesture coordinate (x or y) falls outside the normalized [0,1] range. Emulator touch/gesture points use normalized coordinates relative to the device viewport, so any value below 0 or above 1 is rejected as invalid_argument before being sent to the emulator backend. The function is reused for both x and y of every parsed gesture point.","triggerScenarios":"Passing --points with an x or y value like 1.5, -0.2, or 2; calling emulator gesture/swipe commands whose JSON includes out-of-range coordinates. The check fires after per-point numeric validation, inside parseEmulatorGesturePoints via assertNormalizedCoordinate(x, `points[${index}].x`).","commonSituations":"Authoring gesture JSON with pixel coordinates instead of normalized fractions; assuming the coordinate system is 0..100 or 0..screen-width; copying coordinates from a tool that uses a different normalization.","solutions":["Recompute the coordinate as (pixel_offset / screen_dimension) so it falls within [0,1].","If you have absolute pixels, divide x by device width and y by device height before building the --points JSON.","Validate the points array with a quick script that asserts every x and y is between 0 and 1 inclusive."],"exampleFix":"// before\n--points '[{\"type\":\"begin\",\"x\":540,\"y\":1200}]'\n// after (assuming 1080x2400 screen)\n--points '[{\"type\":\"begin\",\"x\":0.5,\"y\":0.5}]'","handlingStrategy":"validation","validationCode":"function isValidNormalized(n: number): boolean {\n  return typeof n === 'number' && Number.isFinite(n) && n >= 0 && n <= 1;\n}\nconst allCoordsValid = points.every(p => isValidNormalized(p.x) && isValidNormalized(p.y));","typeGuard":"function isNormalizedCoordinate(value: unknown): value is number {\n  return typeof value === 'number' && Number.isFinite(value) && value >= 0 && value <= 1;\n}","tryCatchPattern":null,"preventionTips":["Always convert pixels to fractions: x / screenWidth, y / screenHeight.","Assert every x and y is in [0,1] before serializing the gesture JSON."],"tags":["cli","emulator","gesture","coordinate-validation","normalized"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}