{"record":{"id":"6d847d6d5a0fe6f2","repo":"affaan-m/ECC","slug":"invalid-format-parsed-format-use-text-or-json","errorCode":null,"errorMessage":"Invalid format: ${parsed.format}. Use text or json.","messagePattern":"Invalid format: (.+?)\\. Use text or json\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/harness-audit.js","lineNumber":128,"sourceCode":"    if (arg.startsWith('--scope=')) {\n      parsed.scope = normalizeScope(arg.split('=')[1]);\n      continue;\n    }\n\n    if (arg.startsWith('--root=')) {\n      parsed.root = path.resolve(arg.slice('--root='.length));\n      continue;\n    }\n\n    if (arg.startsWith('-')) {\n      throw new Error(`Unknown argument: ${arg}`);\n    }\n\n    parsed.scope = normalizeScope(arg);\n  }\n\n  if (!['text', 'json'].includes(parsed.format)) {\n    throw new Error(`Invalid format: ${parsed.format}. Use text or json.`);\n  }\n\n  return parsed;\n}\n\nfunction fileExists(rootDir, relativePath) {\n  return fs.existsSync(path.join(rootDir, relativePath));\n}\n\nfunction readText(rootDir, relativePath) {\n  return fs.readFileSync(path.join(rootDir, relativePath), 'utf8');\n}\n\nfunction countFiles(rootDir, relativeDir, extension) {\n  const dirPath = path.join(rootDir, relativeDir);\n  if (!fs.existsSync(dirPath)) {\n    return 0;\n  }","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/harness-audit.js#L110-L146","documentation":"After argument parsing finishes, harness-audit.js verifies that parsed.format is one of 'text' or 'json' (the default is 'text'). Any other value, including an empty string from `--format=`, is rejected. The check is lowercased so `JSON` is accepted but `yaml`/`csv`/`xml` are not.","triggerScenarios":"Running --format=yaml, --format=csv, --format xml, or --format= (empty value after the equals sign).","commonSituations":"Expecting the auditor to emit a format another tool supports, a CI script parameterized with an unsupported format string, or a typo in a wrapper script.","solutions":["Use --format=text or --format=json","Omit --format entirely to accept the default text output","Pipe text/json output through a converter if you need another format downstream"],"exampleFix":"// before\nnode scripts/harness-audit.js --format=yaml\n// after\nnode scripts/harness-audit.js --format=json","handlingStrategy":"validation","validationCode":"const VALID_FORMATS = new Set(['text','json']);\nconst fmt = (parsed.format || 'text').toLowerCase();\nif (!VALID_FORMATS.has(fmt)) {\n  throw new Error(`Unsupported format '${fmt}'. Use text or json.`);\n}","typeGuard":"function isValidFormat(value) {\n  return typeof value === 'string'\n    && ['text','json'].includes(value.toLowerCase());\n}","tryCatchPattern":"try { runAudit(); }\ncatch (err) {\n  if (/^Invalid format:/.test(err.message)) {\n    console.error(err.message);\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Default to omitting --format; text is the default","Whitelist the format string in wrapper scripts before forwarding it"],"tags":["cli","argument-validation","output-format","harness-audit"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}