{"record":{"id":"236b32d7ef6c70d1","repo":"microsoft/playwright","slug":"invalid-color-scheme-should-be-one-of-light-d","errorCode":null,"errorMessage":"Invalid color scheme, should be one of \"light\", \"dark\"","messagePattern":"Invalid color scheme, should be one of \"light\", \"dark\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/cli/browserActions.ts","lineNumber":368,"sourceCode":"    case 'firefox': browserType = playwright.firefox; break;\n    case 'cr': browserType = playwright.chromium; break;\n    case 'wk': browserType = playwright.webkit; break;\n    case 'ff': browserType = playwright.firefox; break;\n  }\n  if (browserType)\n    return browserType;\n  program.help();\n}\n\nfunction validateOptions(options: Options) {\n  if (options.device && !(options.device in playwright.devices)) {\n    const lines = [`Device descriptor not found: '${options.device}', available devices are:`];\n    for (const name in playwright.devices)\n      lines.push(`  \"${name}\"`);\n    throw new Error(lines.join('\\n'));\n  }\n  if (options.colorScheme && !['light', 'dark'].includes(options.colorScheme))\n    throw new Error('Invalid color scheme, should be one of \"light\", \"dark\"');\n}\n","sourceCodeStart":350,"sourceCodeEnd":370,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/cli/browserActions.ts#L350-L370","documentation":"Thrown by validateOptions() in the `playwright open` / `playwright pdf` CLI when the --color-scheme flag receives a value other than 'light' or 'dark'. The CLI option is parsed freely as a string, so this guard rejects unsupported values before launching a browser context. It mirrors the public API contract where colorScheme is typed as 'light'|'dark'|'no-preference'.","triggerScenarios":"Running `npx playwright open --color-scheme=blue url`, `npx open --color-scheme dark-blue`, or any CLI invocation that passes a colorScheme value not in the ['light','dark'] whitelist. The check fires only when options.colorScheme is truthy and not included in the array.","commonSituations":"Typing a custom hex color name, passing 'auto' or 'system', or quoting a value with extra whitespace. Developers sometimes assume the CLI accepts the same values as CSS prefers-color-scheme.","solutions":["Pass exactly 'light' or 'dark': `npx playwright open --color-scheme=dark https://example.com`.","Omit --color-scheme entirely to use the default.","Check for stray whitespace or copy-paste artifacts in the flag value."],"exampleFix":"// before\nnpx playwright open --color-scheme=blue https://example.com\n// after\nnpx playwright open --color-scheme=dark https://example.com","handlingStrategy":"validation","validationCode":"const scheme = process.env.PW_COLOR_SCHEME;\nif (scheme && !['light', 'dark'].includes(scheme))\n  throw new Error(`Unsupported --color-scheme '${scheme}'`);\n// then pass scheme to the CLI or use options programmatically","typeGuard":"function isValidColorScheme(v: string): v is 'light' | 'dark' {\n  return v === 'light' || v === 'dark';\n}","tryCatchPattern":null,"preventionTips":["Restrict the CLI flag value with an enum in any wrapper script.","Document that only 'light' and 'dark' are accepted (no 'auto'/'system')."],"tags":["cli","validation","browser-options"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}