{"record":{"id":"3f9c4e405b3d5899","repo":"affaan-m/ECC","slug":"invalid-format-parsed-format-use-text-json-3f9c4e","errorCode":null,"errorMessage":"Invalid format: ${parsed.format}. Use text, json, or markdown.","messagePattern":"Invalid format: (.+?)\\. Use text, json, or markdown\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/platform-audit.js","lineNumber":206,"sourceCode":"      parsed.thresholds.maxDirtyFiles = parseIntegerFlag(arg.slice('--max-dirty-files='.length), '--max-dirty-files');\n      continue;\n    }\n\n    if (arg === '--use-env-github-token') {\n      parsed.useEnvGithubToken = true;\n      continue;\n    }\n\n    if (arg === '--exit-code') {\n      parsed.exitCode = true;\n      continue;\n    }\n\n    throw new Error(`Unknown argument: ${arg}`);\n  }\n\n  if (!['text', 'json', 'markdown'].includes(parsed.format)) {\n    throw new Error(`Invalid format: ${parsed.format}. Use text, json, or markdown.`);\n  }\n\n  if (parsed.writePath && parsed.format === 'text') {\n    throw new Error('--write requires --json, --markdown, or --format json|markdown');\n  }\n\n  parsed.allowUntracked = parsed.allowUntracked.map(normalizeRelativePrefix);\n\n  return parsed;\n}\n\nfunction normalizeRelativePrefix(value) {\n  return String(value || '')\n    .replace(/\\\\/g, '/')\n    .replace(/^\\.\\/+/, '')\n    .replace(/\\/+$/, '') + (String(value || '').endsWith('/') ? '/' : '');\n}\n","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/platform-audit.js#L188-L224","documentation":"After parsing, platform-audit validates that the requested output format is one of the three supported values: text, json, or markdown. Anything else throws `Invalid format: <value>. Use text, json, or markdown.` A second related check fires when --write is combined with the text format, since machine-readable output is required for file writes.","triggerScenarios":"Passing --format xml, --format md (abbreviation not accepted), an uppercase value like --format JSON, or --write without switching the format away from the text default.","commonSituations":"Assuming common abbreviations ('md') or case-insensitivity work; pipelines that emit FORMAT=xml from a template; using --write but forgetting --json/--markdown so the text-default pairing is rejected.","solutions":["Use exactly one of: --format text, --format json, or --format markdown (lowercase, full words).","Prefer the shorthand flags --json or --markdown instead of --format.","When using --write, always pair it with --json or --markdown (or --format json|markdown).","If the value comes from a variable, normalize it: `fmt=$(echo \"$FMT\" | tr '[:upper:]' '[:lower:]'); [[ $fmt == md ]] && fmt=markdown`."],"exampleFix":"# before\nnode scripts/platform-audit.js --format md --write audit.md\n\n# after\nnode scripts/platform-audit.js --format markdown --write audit.md","handlingStrategy":"validation","validationCode":"const FORMATS = ['text', 'json', 'markdown'];\nif (!FORMATS.includes(format)) throw new Error(`format must be one of ${FORMATS.join('|')}`);\nif (writePath && format === 'text') throw new Error('--write requires json or markdown');","typeGuard":"const isOutputFormat = (v) => v === 'text' || v === 'json' || v === 'markdown';","tryCatchPattern":"try {\n  const parsed = parseArgs(process.argv);\n} catch (err) {\n  if (/^Invalid format/.test(err.message)) {\n    console.error(`${err.message} (shorthands: --json, --markdown)`);\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Use full lowercase format names: text, json, markdown — no 'md' or uppercase.","Prefer the --json / --markdown shorthand flags to avoid --format strings entirely.","Always pair --write with a machine-readable format.","Normalize user/config-supplied format values (lowercase, expand aliases) before passing to the CLI."],"tags":["cli","validation","enum","platform-audit"],"backgroundTag":"invalid-enum-value","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}