{"record":{"id":"976178d418bf5ae5","repo":"affaan-m/ECC","slug":"invalid-format-parsed-format-use-text-or-json-976178","errorCode":null,"errorMessage":"Invalid format: ${parsed.format}. Use text or json.","messagePattern":"Invalid format: (.+?)\\. Use text or json\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/preview-pack-smoke.js","lineNumber":144,"sourceCode":"      continue;\n    }\n\n    if (arg === '--root') {\n      parsed.root = path.resolve(readArgValue(args, index, arg));\n      index += 1;\n      continue;\n    }\n\n    if (arg.startsWith('--root=')) {\n      parsed.root = path.resolve(arg.slice('--root='.length));\n      continue;\n    }\n\n    throw new Error(`Unknown argument: ${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 readText(rootDir, relativePath) {\n  try {\n    return fs.readFileSync(path.join(rootDir, relativePath), 'utf8');\n  } catch (_error) {\n    return '';\n  }\n}\n\nfunction fileExists(rootDir, relativePath) {\n  return fs.existsSync(path.join(rootDir, relativePath));\n}\n\nfunction safeParseJson(text) {","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/preview-pack-smoke.js#L126-L162","documentation":"Thrown after the parse loop in preview-pack-smoke when `parsed.format` is not `text` or `json`. Unlike platform-audit this script supports only two formats (no markdown), since its job is a pass/fail smoke signal best consumed as text or JSON. Set by --format or forced to json by --json.","triggerScenarios":"`--format markdown`, `--format yaml`, `--format ''`, or assuming markdown parity with platform-audit.","commonSituations":"User assumes all ECC audit scripts share the same format set; copy-paste from platform-audit docs; env-derived format string not trimmed.","solutions":["Use `text` (default) or `json` only: `--format json` or `--json`.","If you need markdown, use platform-audit instead — preview-pack-smoke does not emit it.","Trim/lowercase any env-supplied format before passing."],"exampleFix":"# before\nnode scripts/preview-pack-smoke.js --format markdown\n# after\nnode scripts/preview-pack-smoke.js --format json","handlingStrategy":"validation","validationCode":"function normalizePreviewFormat(raw) {\n  const f = String(raw || '').trim().toLowerCase();\n  if (!['text','json'].includes(f)) {\n    throw new Error(`Invalid format: ${f}. Use text or json.`);\n  }\n  return f;\n}","typeGuard":"function isPreviewFormat(value) {\n  return typeof value === 'string' && ['text','json'].includes(value.trim().toLowerCase());\n}","tryCatchPattern":"try {\n  parseArgs(process.argv);\n} catch (err) {\n  if (err.message.startsWith('Invalid format')) {\n    console.error('preview-pack-smoke supports only text or json. Use --json for JSON.');\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Use --json shortcut instead of typing --format json.","Do not assume markdown parity with platform-audit.","Trim/lowercase env-supplied format values."],"tags":["cli","argument-validation","preview-pack-smoke","output-format"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}