{"record":{"id":"db29212b2826a368","repo":"microsoft/playwright","slug":"unknown-command-args-0","errorCode":null,"errorMessage":"Unknown command: ${args._[0]}","messagePattern":"Unknown command: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/tools/trace/traceSnapshot.ts","lineNumber":203,"sourceCode":"  const browser = await playwright.chromium.launch({ headless: true });\n  const context = await browser.newContext();\n  const page = await context.newPage();\n  await page.goto(server.url);\n  await page.waitForURL(url => new URL(url).pathname.startsWith('/snapshot/'));\n\n  const backend = new BrowserBackend({\n    snapshot: { mode: 'full' },\n    skillMode: true,\n  }, context, browserTools);\n  await backend.initialize({ cwd: process.cwd(), clientName: 'playwright-cli' });\n\n  try {\n    if (!browserArgs.length)\n      browserArgs = ['snapshot'];\n    const args = minimist(browserArgs, { string: ['_'] });\n    const command = commands[args._[0]];\n    if (!command)\n      throw new Error(`Unknown command: ${args._[0]}`);\n    const { toolName, toolParams } = parseCommand(command, args as Record<string, string> & { _: string[] });\n    const result = await backend.callTool(toolName, toolParams);\n    const text = result.content[0]?.type === 'text' ? result.content[0].text : undefined;\n    if (text)\n      console.log(text);\n    if (result.isError) {\n      console.error('Command failed.');\n      process.exitCode = 1;\n    }\n  } catch (e) {\n    console.error((e as Error).message);\n    process.exitCode = 1;\n  } finally {\n    await server.stop().catch(e => console.error(e));\n    await gracefullyCloseAll();\n  }\n}\n","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/tools/trace/traceSnapshot.ts#L185-L221","documentation":"Thrown by runCommandOnSnapshot() when the first positional argument (args._[0]) is not a key in the commands map. After a trace snapshot page is served in a headless browser, the CLI dispatches a sub-command against it; an unrecognized sub-command name is rejected here. The command list is imported from the cli-daemon commands module.","triggerScenarios":"Running `npx playwright trace snapshot <actionId> <subcommand>` where <subcommand> is not one of the registered snapshot sub-commands (e.g. a typo like 'slect' instead of 'select').","commonSituations":"Typo in the sub-command; using a command name from a different/newer Playwright version not present in the installed one; passing a flag in the command position by mistake.","solutions":["Check the registered command names for your installed Playwright version and use an exact match.","If you only want to view the snapshot, omit the extra positional argument (the default is 'snapshot').","Upgrade or downgrade Playwright to the version whose command set you are targeting."],"exampleFix":"// before\nnpx playwright trace snapshot 5 slect option\n// after\nnpx playwright trace snapshot 5 select option","handlingStrategy":"validation","validationCode":"import { commands } from '../cli-daemon/commands';\nfunction assertKnownCommand(name: string) {\n  if (!(name in commands)) {\n    throw new Error(`Unknown command: ${name}. Known: ${Object.keys(commands).join(', ')}`);\n  }\n}","typeGuard":"function isKnownCommand(name: string): name is keyof typeof commands {\n  return name in commands;\n}","tryCatchPattern":null,"preventionTips":["Validate the sub-command against the installed version's command list before dispatch.","Avoid passing free-text user input directly as the sub-command position.","Pin the Playwright version so the command set is stable."],"tags":["trace","cli","snapshot","command","validation"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}