{"record":{"id":"8ae91877bfad8764","repo":"GoogleChrome/lighthouse","slug":"str-is-not-a-valid-output-value-argument","errorCode":null,"errorMessage":"\"${str}\" is not a valid 'output' value. Argument 'output' must be an array from choices \"json\", \"html\", \"csv\"","messagePattern":"\"(.+?)\" is not a valid 'output' value\\. Argument 'output' must be an array from choices \"json\", \"html\", \"csv\"","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/cli-flags.js","lineNumber":399,"sourceCode":"  return value;\n}\n\n/**\n * Coerce output CLI input to `LH.SharedFlagsSettings['output']` or throw if not possible.\n * @param {Array<unknown>} values\n * @return {Array<LH.OutputMode>}\n */\nfunction coerceOutput(values) {\n  const outputTypes = ['json', 'html', 'csv'];\n  const errorHint = `Argument 'output' must be an array from choices \"${outputTypes.join('\", \"')}\"`;\n  if (!values.every(item => typeof item === 'string')) {\n    throw new Error('Invalid values. ' + errorHint);\n  }\n  // Allow parsing of comma-separated values.\n  const strings = values.flatMap(value => value.split(','));\n  const validValues = strings.filter(/** @return {str is LH.OutputMode} */ str => {\n    if (!outputTypes.includes(str)) {\n      throw new Error(`\"${str}\" is not a valid 'output' value. ` + errorHint);\n    }\n    return true;\n  });\n\n  return validValues;\n}\n\n/**\n * Verifies outputPath is something we can actually write to.\n * @param {unknown=} value\n * @return {string=}\n */\nfunction coerceOutputPath(value) {\n  if (value === undefined) return;\n\n  if (typeof value !== 'string' || !value || !fs.existsSync(path.dirname(value))) {\n    throw new Error(`--output-path (${value}) cannot be written to`);\n  }","sourceCodeStart":381,"sourceCodeEnd":417,"githubUrl":"https://github.com/GoogleChrome/lighthouse/blob/9515cd4e58ebed69f78742d932b501c2cab8ad8f/cli/cli-flags.js#L381-L417","documentation":"After confirming all --output values are strings, coerceOutput splits on commas and checks each individual value against the allowed set ['json', 'html', 'csv']. This error fires for a specific invalid string value, naming it in the message. It is the more common and more user-friendly sibling of error 3.","triggerScenarios":"Passing --output with a string value that is not 'json', 'html', or 'csv'. For example: --output=xml, --output=pdf, --output=JSON (case-sensitive), or a comma-separated list containing a typo like --output=json,htm.","commonSituations":"Typing a format name incorrectly (htm instead of html); using wrong case (JSON instead of json); requesting an unsupported format like xml or pdf; copy-paste errors in scripts.","solutions":["Use one of the three valid values: json, html, or csv (lowercase only)","For multiple formats, use comma separation with valid values: --output=json,html","Check for typos and case sensitivity in the format name"],"exampleFix":"# before\nlighthouse --output=JSON --output=htm https://example.com\n# after\nlighthouse --output=json --output=html https://example.com","handlingStrategy":"validation","validationCode":"// Validate output format choices before running\nconst VALID_OUTPUTS = ['json', 'html', 'csv'];\nfunction validateOutputFormats(values) {\n  const formats = values.flatMap(v => v.split(','));\n  for (const f of formats) {\n    if (!VALID_OUTPUTS.includes(f)) {\n      throw new Error(`Invalid output format: ${f}. Valid: ${VALID_OUTPUTS.join(', ')}`);\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use lowercase format names only: json, html, csv","Double-check for typos like 'htm' or 'JSON' before running","Define output formats as constants in scripts to avoid typos"],"tags":["cli","validation","output"],"backgroundTag":null,"analyzedSha":"9515cd4e58ebed69f78742d932b501c2cab8ad8f","analyzedAt":"2026-08-13T06:28:10.346Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}