{"record":{"id":"acabcaa0c8093376","repo":"tailwindlabs/tailwindcss","slug":"invalid-value-for-format-input","errorCode":null,"errorMessage":"Invalid value for --format: ${input}","messagePattern":"Invalid value for --format: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@tailwindcss-cli/src/commands/canonicalize/index.ts","lineNumber":289,"sourceCode":"  let content = await fs.readFile(resolvedCssFile, 'utf8')\n  return __unstable__loadDesignSystem(content, {\n    base: path.dirname(resolvedCssFile),\n  })\n}\n\nfunction splitCandidateGroups(input: string) {\n  return input\n    .split(/\\r?\\n/g)\n    .map((line) => line.trim())\n    .filter((line) => line.length > 0)\n}\n\nfunction parseFormat(input: string): OutputFormat {\n  if (input === 'text' || input === 'json' || input === 'jsonl') {\n    return input\n  }\n\n  throw new Error(`Invalid value for --format: ${input}`)\n}\n\nfunction usageError(message: string): RunCommandLineResult {\n  return {\n    exitCode: 1,\n    stdout: helpMessage() ?? '',\n    stderr: message,\n  }\n}\n\nfunction splitCandidates(input: string) {\n  let trimmedInput = input.trim()\n  if (trimmedInput.length === 0) return []\n\n  return segment(trimmedInput, ' ')\n    .map((candidate) => candidate.trim())\n    .filter((candidate) => candidate.length > 0)\n}","sourceCodeStart":271,"sourceCodeEnd":307,"githubUrl":"https://github.com/tailwindlabs/tailwindcss/blob/16e94cbf7f965c5ad697e90e940b5e178efad67c/packages/@tailwindcss-cli/src/commands/canonicalize/index.ts#L271-L307","documentation":"The `canonicalize` CLI subcommand accepts only three `--format` values: `text`, `json`, and `jsonl`. `parseFormat` does an exact-match comparison against these and throws for anything else, so a typo or an unsupported format fails fast with a descriptive message rather than producing malformed output.","triggerScenarios":"Running `tailwindcss canonicalize --format xml ...` (or yaml, csv, pretty, etc.). The argument fails all three equality checks in `parseFormat` and throws at index.ts:289. Note: the result is intended to be turned into a usage error by the caller (`usageError`), but the raw throw surfaces if `parseFormat` is called directly.","commonSituations":"Scripting around the canonicalize command with a guessed format name, or a CI flag value coming from an env var that is empty or misspelled.","solutions":["Set `--format` to one of `text`, `json`, or `jsonl`.","If invoking `parseFormat` programmatically, validate the input against the set `['text','json','jsonl']` before calling, and route failures through `usageError` to print help on stderr."],"exampleFix":"# before\ntailwindcss canonicalize --format yaml\n\n# after\ntailwindcss canonicalize --format json","handlingStrategy":"validation","validationCode":"const FORMATS = new Set(['text', 'json', 'jsonl'])\nfunction safeParseFormat(input: string): OutputFormat | never {\n  if (!FORMATS.has(input)) {\n    process.stderr.write(`Invalid --format: ${input}. Valid: ${[...FORMATS].join(', ')}\\n`)\n    process.exit(1)\n  }\n  return input as OutputFormat\n}","typeGuard":"function isOutputFormat(v: string): v is OutputFormat {\n  return v === 'text' || v === 'json' || v === 'jsonl'\n}","tryCatchPattern":null,"preventionTips":["Validate --format against text/json/jsonl before invoking canonicalize.","Drive the flag from a typed enum in scripts rather than free-form strings.","Surface invalid values via usageError to print help on stderr."],"tags":["cli","argument-validation","canonicalize"],"backgroundTag":null,"analyzedSha":"16e94cbf7f965c5ad697e90e940b5e178efad67c","analyzedAt":"2026-08-12T06:02:42.469Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}