{"record":{"id":"ba163bd1ec600611","repo":"microsoft/playwright","slug":"invalid-resolution-format-use-name-800x600","errorCode":null,"errorMessage":"Invalid resolution format: use ${name}=\"800x600\"","messagePattern":"Invalid resolution format: use (.+?)=\"800x600\"","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/tools/mcp/config.ts","lineNumber":573,"sourceCode":"export function dotenvFileLoader(value: string | undefined): Record<string, string> | undefined {\n  if (!value)\n    return undefined;\n  return dotenv.parse(fs.readFileSync(value, 'utf8'));\n}\n\nexport function numberParser(value: string | undefined): number | undefined {\n  if (!value)\n    return undefined;\n  return +value;\n}\n\nexport function resolutionParser(name: string, value: string | undefined): ViewportSize | undefined {\n  if (!value)\n    return undefined;\n  if (value.includes('x')) {\n    const [width, height] = value.split('x').map(v => +v);\n    if (isNaN(width) || isNaN(height) || width <= 0 || height <= 0)\n      throw new Error(`Invalid resolution format: use ${name}=\"800x600\"`);\n    return { width, height };\n  }\n\n  // Legacy format\n  if (value.includes(',')) {\n    const [width, height] = value.split(',').map(v => +v);\n    if (isNaN(width) || isNaN(height) || width <= 0 || height <= 0)\n      throw new Error(`Invalid resolution format: use ${name}=\"800x600\"`);\n    return { width, height };\n  }\n\n  throw new Error(`Invalid resolution format: use ${name}=\"800x600\"`);\n}\n\nexport function headerParser(arg: string | undefined, previous?: Record<string, string>): Record<string, string> | undefined {\n  if (!arg)\n    return previous;\n  const result: Record<string, string> = { ...(previous ?? {}) };","sourceCodeStart":555,"sourceCodeEnd":591,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/tools/mcp/config.ts#L555-L591","documentation":"Thrown by resolutionParser() when the value contains an 'x' separator but the two halves cannot be parsed into two positive numbers (NaN, zero, or negative). This parser backs --viewport-style CLI options, so the error fires during argument parsing, before any browser is launched.","triggerScenarios":"Passing a viewport/resolution value like `--viewport 800x`, `--viewport x600`, `--viewport axb`, or `--viewport 0x600`.","commonSituations":"Typo in the dimensions; copy-pasting a value with a multiplication sign (×, U+00D7) instead of ASCII 'x'; trailing units like `800x600px`; negative or zero values from a variable.","solutions":["Provide two positive integers separated by a single ASCII 'x', e.g. `--viewport 800x600`.","If the value comes from a variable, validate/sanitize it before passing it to the CLI.","Ensure you used the ASCII letter 'x' and not a multiplication sign or capital 'X' adjacent to a non-numeric string."],"exampleFix":"// before\n--viewport 800x600px\n// after\n--viewport 800x600","handlingStrategy":"validation","validationCode":"function parseResolution(v: string): { width: number; height: number } {\n  const m = /^(\\d+)x(\\d+)$/.exec(v);\n  if (!m) throw new Error(`Invalid resolution: ${v}. Use WIDTHxHEIGHT, e.g. 800x600.`);\n  const [w, h] = [+m[1], +m[2]];\n  if (w <= 0 || h <= 0) throw new Error('Width and height must be positive.');\n  return { width: w, height: h };\n}","typeGuard":"function isValidResolution(v: string): boolean {\n  const m = /^(\\d+)x(\\d+)$/.exec(v);\n  return !!m && +m[1] > 0 && +m[2] > 0;\n}","tryCatchPattern":null,"preventionTips":["Validate resolution strings with a WIDTHxHEIGHT regex before passing to the CLI.","Normalize values (strip units, replace multiplication signs) in your own code.","Treat viewport as structured data ({width,height}) until the moment you serialize it."],"tags":["mcp","config","cli","parser","viewport","validation"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}