{"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":"validation","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/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/operator-readiness-dashboard.js#L200-L236","documentation":"After argument parsing, parseArgs validates that the selected output format is one of the allowed enum values: text, json, or markdown. If --format (or a format shorthand) produced any other string, this error is thrown to prevent writing an unsupported output type.","triggerScenarios":"Calling `node scripts/operator-readiness-dashboard.js --format xml`, `--format html`, `--format JSON` (case-sensitive), or leaving parsed.format corrupted to a non-enum default triggers the `!['text','json','markdown'].includes(parsed.format)` check.","commonSituations":"Typos in the format value; assuming case-insensitive matching ('JSON' fails); using a format from a different tool ('yaml', 'csv'); a wrapper script interpolating an empty or wrong value into --format.","solutions":["Use exactly one of: text, json, markdown (lowercase).","Prefer the shorthand flags --json or --markdown which set the format directly.","Check wrapper/CI scripts for variables that may be empty or wrong, e.g. `--format \"$FMT\"`.","To support a new format, add it to the allowed list and implement rendering in main()."],"exampleFix":"// before\nnode scripts/operator-readiness-dashboard.js --format html\n// after\nnode scripts/operator-readiness-dashboard.js --format markdown","handlingStrategy":"validation","validationCode":"const FORMATS = ['text','json','markdown'];\nif (format !== undefined && !FORMATS.includes(format)) {\n  throw new Error(`Invalid format: ${format}. Use text, json, or markdown.`);\n}","typeGuard":"function isDashboardFormat(v) { return v === 'text' || v === 'json' || v === 'markdown'; }","tryCatchPattern":"try {\n  const parsed = parseArgs(args);\n} catch (err) {\n  if (err.message.startsWith('Invalid format:')) {\n    console.error(`${err.message} (accepted: text, json, markdown)`);\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Use the --json/--markdown shorthands instead of free-text --format","Lowercase format values in wrapper scripts before passing them","Define the format string as a constant in CI configs","Keep the allowed-format list as the single source of truth"],"tags":["cli","validation","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}