{"record":{"id":"7162231c0b244e00","repo":"microsoft/playwright","slug":"invalid-name-value-valid-values-are-opt","errorCode":null,"errorMessage":"Invalid ${name}: ${value}. Valid values are: ${options.join(', ')}","messagePattern":"Invalid (.+?): (.+?)\\. Valid values are: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/tools/mcp/config.ts","lineNumber":602,"sourceCode":"\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 ?? {}) };\n  const colonIndex = arg.indexOf(':');\n\n  const name = colonIndex === -1 ? arg.trim() : arg.substring(0, colonIndex).trim();\n  const value = colonIndex === -1 ? '' : arg.substring(colonIndex + 1).trim();\n  result[name] = value;\n  return result;\n}\n\nexport function enumParser<T extends string>(name: string, options: T[], value: string): T {\n  if (!options.includes(value as T))\n    throw new Error(`Invalid ${name}: ${value}. Valid values are: ${options.join(', ')}`);\n  return value as T;\n}\n\nfunction envToBoolean(value: string | undefined): boolean | undefined {\n  if (value === 'true' || value === '1')\n    return true;\n  if (value === 'false' || value === '0')\n    return false;\n  return undefined;\n}\n\nfunction envToString(value: string | undefined): string | undefined {\n  return value ? value.trim() : undefined;\n}\n","sourceCodeStart":584,"sourceCodeEnd":617,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/tools/mcp/config.ts#L584-L617","documentation":"Thrown by enumParser() when a string value is not a member of the allowed options array. enumParser is a generic helper used by CLI option definitions to restrict values (e.g. browser names, snapshot modes), so the error names the option, the bad value, and the full list of legal values.","triggerScenarios":"Passing an unrecognized value to a constrained CLI option, e.g. `--browser safari` when only chromium/firefox/webkit/chrome variants are accepted, or a snapshot mode outside the allowed set.","commonSituations":"Typo in an option value; assuming a value is supported when it is not (e.g. 'safari' vs 'webkit'); version skew where a newer/older option value is not in the installed version's allowed list.","solutions":["Read the 'Valid values are:' list in the error message and pick one of those exact strings.","Check for typos and casing — the comparison is case-sensitive.","Confirm the value is supported in your installed Playwright version (upgrade or pick a supported value)."],"exampleFix":"// before\n--browser safari\n// after\n--browser webkit","handlingStrategy":"validation","validationCode":"function assertEnum<T extends string>(name: string, value: string, options: readonly T[]): T {\n  if (!options.includes(value as T))\n    throw new Error(`Invalid ${name}: ${value}. Valid: ${options.join(', ')}`);\n  return value as T;\n}","typeGuard":"function isOneOf<T extends string>(value: string, options: readonly T[]): value is T {\n  return (options as readonly string[]).includes(value);\n}","tryCatchPattern":null,"preventionTips":["Keep a shared constant of allowed values and validate against it in your wrapper.","Use autocomplete-friendly constants rather than free-text strings in config.","Pin the Playwright version so the allowed value set matches what you code against."],"tags":["mcp","config","cli","parser","enum","validation"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}