{"record":{"id":"5261260156866f5e","repo":"affaan-m/ECC","slug":"invalid-format-parsed-format-use-text-json-526126","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/operator-readiness-dashboard.js","lineNumber":218,"sourceCode":"      index += 1;\n      continue;\n    }\n\n    if (arg.startsWith('--generated-at=')) {\n      parsed.generatedAt = arg.slice('--generated-at='.length);\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).filter(Boolean);\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}","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/operator-readiness-dashboard.js#L200-L236","documentation":"Thrown by parseArgs in scripts/operator-readiness-dashboard.js after parsing, when the resolved format is not one of text, json, or markdown. Format is set by --json (sets 'json'), --markdown (sets 'markdown'), or --format/--format= directly. An unrecognized --format value or a default-then-overwritten path lands here.","triggerScenarios":"Passing `--format yaml`, `--format html`, or `--format csv`. Passing `--format=` with an empty value. Note the format value is NOT lowercased here (unlike observability-readiness.js), so `JSON` would also be rejected.","commonSituations":"Case mismatch (`JSON` vs `json`); assuming the format strings of another tool; an empty shell variable expanding into `--format=`.","solutions":["Use one of: --json, --markdown, or omit the flag (defaults to text).","If using --format explicitly, pass a lowercase 'text', 'json', or 'markdown'.","Quote and validate shell variables so empty values are caught before invocation."],"exampleFix":"// before\nnode scripts/operator-readiness-dashboard.js --format yaml\n// after\nnode scripts/operator-readiness-dashboard.js --format markdown","handlingStrategy":"validation","validationCode":"const DASH_FORMATS = new Set(['text', 'json', 'markdown']);\nfunction normalizeDashFormat(raw) {\n  const f = String(raw || '').toLowerCase();\n  if (!DASH_FORMATS.has(f)) throw new Error(`Unsupported format '${raw}'. Use text, json, or markdown.`);\n  return f;\n}","typeGuard":"function isDashFormat(value) {\n  return typeof value === 'string' && DASH_FORMATS.has(value.toLowerCase());\n}","tryCatchPattern":null,"preventionTips":["Note this script does not lowercase --format itself; pass lowercase to be safe.","Prefer the dedicated --json / --markdown toggles over --format when possible.","Validate format before building argv so CI fails at the configuration stage."],"tags":["cli","operator-dashboard","argument-validation"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}