{"record":{"id":"885dd488360b8095","repo":"microsoft/playwright","slug":"invalid-location-params-location-expected-fo","errorCode":null,"errorMessage":"Invalid location \"${params.location}\", expected format is <file>:<line>, e.g. \"example.spec.ts:42\"","messagePattern":"Invalid location \"(.+?)\", expected format is <file>:<line>, e\\.g\\. \"example\\.spec\\.ts:42\"","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/tools/backend/devtools.ts","lineNumber":63,"sourceCode":"        if (browserContext.debugger.pausedDetails()) {\n          browserContext.debugger.off('pausedstatechanged', listener);\n          resolve();\n        }\n      };\n      browserContext.debugger.on('pausedstatechanged', listener);\n      browserContext.once('close', () => {\n        browserContext.debugger.off('pausedstatechanged', listener);\n        resolve();\n      });\n    });\n\n    if (params.location) {\n      const [file, lineStr] = params.location.split(':');\n      let location;\n      if (lineStr) {\n        const line = Number(lineStr);\n        if (isNaN(line))\n          throw new Error(`Invalid location \"${params.location}\", expected format is <file>:<line>, e.g. \"example.spec.ts:42\"`);\n        location = { file, line };\n      } else {\n        location = { file: params.location };\n      }\n      await browserContext.debugger.runTo(location);\n    } else if (params.step) {\n      await browserContext.debugger.next();\n    } else {\n      await browserContext.debugger.resume();\n    }\n    await pausedPromise;\n  },\n});\n\nconst highlight = defineTabTool({\n  capability: 'devtools',\n  schema: {\n    name: 'browser_highlight',","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/tools/backend/devtools.ts#L45-L81","documentation":"Thrown by the browser_resume devtools tool when params.location contains a colon-separated second segment that is not a valid number. The parser does params.location.split(':') and runs Number(lineStr); if that yields NaN the location is rejected with the documented <file>:<line> contract. A bare file with no colon is accepted (file-only location).","triggerScenarios":"Invoking browser_resume with location like \"foo.spec.ts:abc\" or \"foo.spec.ts:\" where the line part is non-numeric.","commonSituations":"Agent pasting a stack-trace fragment that includes a column (\"file.ts:12:34\") — split keeps \"12:34\" which is NaN; using a symbol or empty line segment.","solutions":["Pass location as \"<file>:<integer-line>\", e.g. \"example.spec.ts:42\".","Strip any column segment before passing: keep only the first colon and a numeric line.","If you only know the file, omit the line entirely so the file-only branch is used."],"exampleFix":"// before\nawait resume({ location: 'tests/login.spec.ts:14:8' }); // '14:8' -> NaN -> throws\n\n// after\nconst [f, l] = 'tests/login.spec.ts:14:8'.split(':');\nawait resume({ location: `${f}:${l}` }); // 'tests/login.spec.ts:14'","handlingStrategy":"validation","validationCode":"function parseLocation(raw: string): { file: string; line?: number } | null {\n  const idx = raw.indexOf(':');\n  if (idx === -1) return { file: raw };\n  const file = raw.slice(0, idx);\n  const lineStr = raw.slice(idx + 1);\n  // reject any extra colon-separated segments by re-checking for ':'\n  if (lineStr.includes(':')) return null;\n  const line = Number(lineStr);\n  if (!Number.isInteger(line) || line < 1) return null;\n  return { file, line };\n}\n\nconst loc = parseLocation(input);\nif (!loc) throw new Error('Use <file>:<line>, e.g. \"example.spec.ts:42\"');","typeGuard":"function isValidLocation(s: string): boolean {\n  return /^(?:[^:]+)(?::\\d+)?$/.test(s);\n}","tryCatchPattern":"try {\n  await resume({ location: input });\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Invalid location')) {\n    // prompt the user / agent for <file>:<line> and retry\n  } else throw e;\n}","preventionTips":["Strip column offsets from pasted stack traces before passing as location.","Prefer passing only a file when you do not need a specific line.","Validate with a regex /^(?:[^:]+)(?::\\d+)?$/ before invoking the tool."],"tags":["devtools","debugger","input-validation","mcp-tool"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}