{"record":{"id":"660d438925e4ac66","repo":"affaan-m/ECC","slug":"invalid-format-parsed-format-use-text-json","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/discussion-audit.js","lineNumber":145,"sourceCode":"      parsed.first = parseIntegerFlag(arg.slice('--first='.length), '--first');\n      continue;\n    }\n\n    if (arg === '--use-env-github-token') {\n      parsed.useEnvGithubToken = true;\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  return parsed;\n}\n\nfunction buildReport(options) {\n  const repos = options.repos.length > 0 ? options.repos : DEFAULT_REPOS;\n  const repoReports = repos.map(repo => {\n    try {\n      return {\n        repo,\n        discussions: fetchDiscussionSummary(repo, options),\n      };\n    } catch (error) {","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/discussion-audit.js#L127-L163","documentation":"After all arguments are parsed, discussion-audit.js validates that the --format value is one of 'text', 'json', or 'markdown'. The format can be set via --format <value>, --format=<value>, --json (sets json), or --markdown (sets markdown). Any other value — including case-variant typos like 'JSON', abbreviations like 'md', or unsupported formats like 'xml' or 'csv' — triggers this error.","triggerScenarios":"Passing --format xml, --format md (abbreviation for markdown), --format YAML, or a typo. The value is lowercased before validation, so 'JSON' would become 'json' and pass, but 'jsno' or 'xml' would not.","commonSituations":"Users abbreviating 'markdown' as 'md' or 'mdown'; users trying custom output formats; case typos that don't survive lowercasing; passing a format name from a different tool.","solutions":["Use exactly 'text', 'json', or 'markdown' as the format value","Use the --json or --markdown shortcut flags instead of --format","Remember the value is case-insensitive (lowercased internally) but must be the full word"],"exampleFix":"// before\nnode scripts/discussion-audit.js --format md\nnode scripts/discussion-audit.js --format xml\n// after\nnode scripts/discussion-audit.js --format markdown\n// or\nnode scripts/discussion-audit.js --markdown","handlingStrategy":"validation","validationCode":"// Validate the format value before passing it\nconst VALID_FORMATS = new Set(['text', 'json', 'markdown']);\nconst format = (process.env.AUDIT_FORMAT || 'text').toLowerCase();\nif (!VALID_FORMATS.has(format)) {\n  console.error(`Invalid format: ${format}. Use text, json, or markdown.`);\n  process.exit(1);\n}","typeGuard":"// Type guard for a valid output format\nfunction isValidOutputFormat(value) {\n  return typeof value === 'string' && ['text', 'json', 'markdown'].includes(value.toLowerCase());\n}","tryCatchPattern":"try {\n  const options = parseArgs(process.argv);\n} catch (error) {\n  if (error.message.startsWith('Invalid format:')) {\n    console.error(error.message);\n    console.error('Use --json or --markdown as shortcuts, or --format text|json|markdown');\n    process.exit(2);\n  }\n  throw error;\n}","preventionTips":["Use only 'text', 'json', or 'markdown' as format values","Use the --json or --markdown shortcut flags instead of --format for clarity","The value is lowercased internally, so case does not matter for the three valid names","Do not use abbreviations like 'md' — spell out the full format name"],"tags":["cli","argument-parsing","validation","discussion-audit"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}