{"record":{"id":"ff43e797abc2a0a1","repo":"affaan-m/ECC","slug":"invalid-format-parsed-format-use-text-or-json-ff43e7","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/release-approval-gate.js","lineNumber":162,"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":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/release-approval-gate.js#L144-L180","documentation":"Thrown after the parse loop in release-approval-gate when `parsed.format` is not `text` or `json`. This gate, like preview-pack-smoke, supports only two output formats: text (default, human-readable verdict) and json (machine-parseable for CI). Set via --format or forced to json by --json.","triggerScenarios":"`--format markdown`, `--format yaml`, `--format ''`, or assuming markdown support parity with platform-audit.","commonSituations":"User copies a --format value from platform-audit docs; env-derived format with whitespace/newline; expecting parity across all ECC gates.","solutions":["Use `text` (default) or `json`: `--format json` or `--json`.","For markdown reports use platform-audit, which supports it.","Trim and lowercase any env-supplied format before forwarding."],"exampleFix":"# before\nnode scripts/release-approval-gate.js --format markdown\n# after\nnode scripts/release-approval-gate.js --format json","handlingStrategy":"validation","validationCode":"function normalizeGateFormat(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 isGateFormat(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('release-approval-gate supports only text or json. Use --json for JSON.');\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Use --json shortcut rather than typing --format json.","Do not assume markdown support — use platform-audit for markdown.","Trim/lowercase env-supplied format values before forwarding."],"tags":["cli","argument-validation","release-approval-gate","output-format"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}