{"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":"exception","errorClass":"Error","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/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/platform-audit.js#L188-L224","documentation":"Thrown after the parse loop in platform-audit when `parsed.format` is not one of text/json/markdown. Format is set by --format, --json (forces json), or --markdown (forces markdown), and is lowercased on input; this guard catches unsupported values, empty strings, or a misspelled format.","triggerScenarios":"`--format yaml`, `--format HTML`, `--format ''`, or a downstream consumer expecting a format this version does not emit.","commonSituations":"User assumes a format exists that was never added; env-derived format string with trailing whitespace/newline not trimmed; copy from documentation of a fork.","solutions":["Use one of the supported values: `--format json` (or `--json` / `--markdown`).","If the value is env-supplied, trim and lowercase it before passing.","Remember `text` is the default — omit --format entirely if human-readable output is fine."],"exampleFix":"# before\nnode scripts/platform-audit.js --format yaml\n# after\nnode scripts/platform-audit.js --format json","handlingStrategy":"validation","validationCode":"const VALID_FORMATS = new Set(['text', 'json', 'markdown']);\nfunction normalizeFormat(raw) {\n  const f = String(raw || '').trim().toLowerCase();\n  if (!VALID_FORMATS.has(f)) {\n    throw new Error(`Invalid format: ${f}. Use text, json, or markdown.`);\n  }\n  return f;\n}","typeGuard":"function isPlatformAuditFormat(value) {\n  return typeof value === 'string' && ['text','json','markdown'].includes(value.trim().toLowerCase());\n}","tryCatchPattern":"try {\n  parseArgs(process.argv);\n} catch (err) {\n  if (err.message.startsWith('Invalid format')) {\n    console.error('Supported formats: text (default), json, markdown.');\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Use --json or --markdown shortcuts to avoid typos in --format.","Trim and lowercase env-supplied format strings.","Remember text is the default — omit the flag if unsure."],"tags":["cli","argument-validation","platform-audit","output-format"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}