{"record":{"id":"dda3f4d4423e333b","repo":"microsoft/playwright","slug":"tab-index-is-required","errorCode":null,"errorMessage":"Tab index is required","messagePattern":"Tab index is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/tools/backend/tabs.ts","lineNumber":57,"sourceCode":"        await context.ensureTab();\n        break;\n      }\n      case 'new': {\n        const tab = await context.newTab();\n        if (params.url) {\n          const url = await tab.checkUrlAndNavigate(params.url);\n          response.setIncludeSnapshot();\n          response.addAction({ name: 'navigate', url });\n        }\n        break;\n      }\n      case 'close': {\n        await context.closeTab(params.index);\n        break;\n      }\n      case 'select': {\n        if (params.index === undefined)\n          throw new Error('Tab index is required');\n        await context.selectTab(params.index);\n        break;\n      }\n    }\n    const tabHeaders = await Promise.all(context.tabs().map(tab => tab.headerSnapshot()));\n    const result = renderTabsMarkdown(tabHeaders);\n    response.addTextResult(result.join('\\n'));\n  },\n});\n\nexport default [\n  browserTabs,\n];\n","sourceCodeStart":39,"sourceCodeEnd":71,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/tools/backend/tabs.ts#L39-L71","documentation":"Thrown by the browser_tabs tool's 'select' action when params.index is undefined. The select action semantically requires a target tab index (unlike list/navigate which can operate on the current tab).","triggerScenarios":"Calling browser_tabs with action:'select' and omitting index, or passing index: undefined explicitly.","commonSituations":"Agent assumes 'select' defaults to current tab; index field dropped during JSON construction; confusing 'select' with 'list'.","solutions":["Provide params.index as a non-negative integer that exists in context.tabs().","If you meant the current tab, you do not need 'select' — omit the action or use 'list'.","Resolve the desired index from a prior browser_tabs list call."],"exampleFix":"// before\nawait client.callTool('browser_tabs', { action: 'select' }); // throws\n\n// after\nawait client.callTool('browser_tabs', { action: 'select', index: 2 });","handlingStrategy":"validation","validationCode":"function validateTabsSelect(params: { action: string; index?: number }) {\n  if (params.action === 'select' && (params.index === undefined || !Number.isInteger(params.index) || params.index < 0))\n    throw new Error('browser_tabs select requires a non-negative integer index');\n}","typeGuard":"function hasTabIndex(p: { action?: string; index?: unknown }): p is { action: 'select'; index: number } {\n  return p.action === 'select' && typeof p.index === 'number' && Number.isInteger(p.index) && p.index >= 0;\n}","tryCatchPattern":"try {\n  await client.callTool('browser_tabs', params);\n} catch (e) {\n  if (e instanceof Error && e.message === 'Tab index is required') {\n    // list tabs first, choose an index, retry\n    await client.callTool('browser_tabs', { action: 'list' });\n  } else throw e;\n}","preventionTips":["Always list tabs before selecting to obtain a valid index.","Treat the index as ephemeral; it changes when tabs open/close."],"tags":["tabs","input-validation","mcp-tool"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}