{"record":{"id":"806b2335f7125176","repo":"stablyai/orca","slug":"invalid-argument-806b23","errorCode":"invalid_argument","errorMessage":"Missing required --index or --page","messagePattern":"Missing required --index or --page","errorType":"exception","errorClass":"RuntimeClientError","httpStatus":null,"severity":"error","filePath":"src/cli/handlers/browser-tab.ts","lineNumber":40,"sourceCode":"    printResult(result, json, (value) =>\n      showProfile ? formatTabListWithProfiles(value, true) : formatTabList(value)\n    )\n  },\n  'tab show': async ({ flags, client, cwd, json }) => {\n    const target = await getBrowserCommandTarget(flags, cwd, client)\n    const result = await client.call<BrowserTabShowResult>('browser.tabShow', target)\n    printResult(result, json, formatTabShow)\n  },\n  'tab current': async ({ flags, client, cwd, json }) => {\n    const worktree = await getBrowserWorktreeSelector(flags, cwd, client)\n    const result = await client.call<BrowserTabCurrentResult>('browser.tabCurrent', { worktree })\n    printResult(result, json, formatTabShow)\n  },\n  'tab switch': async ({ flags, client, cwd, json }) => {\n    const index = getOptionalNonNegativeIntegerFlag(flags, 'index')\n    const page = getOptionalStringFlag(flags, 'page')\n    if (index === undefined && !page) {\n      throw new RuntimeClientError('invalid_argument', 'Missing required --index or --page')\n    }\n    // Why: a stable browser page id is globally unique across Orca, so page-\n    // targeted tab switches should match the rest of the --page command model:\n    // global by default, with --worktree only acting as explicit validation.\n    const target = await getBrowserCommandTarget(flags, cwd, client)\n    // Why: --focus is an opt-in side effect. The renderer's handler is\n    // worktree-scoped: it surfaces the browser pane only when the user is\n    // already on the targeted worktree, otherwise it pre-stages silently.\n    // Spread conditionally so the RPC payload stays shape-identical to the\n    // pre-flag form when --focus is absent.\n    const result = await client.call<BrowserTabSwitchResult>('browser.tabSwitch', {\n      index,\n      page,\n      ...(flags.has('focus') ? { focus: true } : {}),\n      ...target\n    })\n    printResult(result, json, (v) => `Switched to tab ${v.switched} (${v.browserPageId})`)\n  },","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/cli/handlers/browser-tab.ts#L22-L58","documentation":"Thrown by the `tab switch` handler when neither --index nor --page is supplied. tab switch needs a target — either a numeric tab index (via getOptionalNonNegativeIntegerFlag) or a stable browser page id string (via getOptionalStringFlag). With both undefined/empty, there is nothing to switch to.","triggerScenarios":"Running `orca tab switch` with no target flags, or with only unrelated flags like --focus/--worktree. The `index === undefined && !page` guard fires before getBrowserCommandTarget is called.","commonSituations":"Assuming tab switch defaults to 'next' tab, forgetting the target after refactoring a script, or passing the page id into the wrong flag name.","solutions":["Add `--index <n>` (zero-based non-negative) or `--page <browserPageId>` to the command.","If you meant to focus the current tab rather than switch, use `tab current` instead.","Confirm the page id was copied from a `tab show`/`tab current` result and not truncated."],"exampleFix":"// before\norca tab switch\n// after\norca tab switch --index 2","handlingStrategy":"validation","validationCode":"function requireTabSwitchTarget(flags: Map<string, string | boolean>): void {\n  const index = getOptionalNonNegativeIntegerFlag(flags, 'index')\n  const page = getOptionalStringFlag(flags, 'page')\n  if (index === undefined && !page) {\n    throw new Error('tab switch requires --index <n> or --page <browserPageId>')\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass a target to tab switch; it does not default to 'next'.","Capture browserPageId from tab show/current output before constructing a --page switch.","Validate the presence of one target flag in wrapper scripts."],"tags":["cli","browser","tab","flag-validation","invalid-argument"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}