affaan-m/ECC · error · Error

Invalid format: ${parsed.format}. Use text, json, or markdow

Error message

Invalid format: ${parsed.format}. Use text, json, or markdown.

What it means

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.

Source

Thrown at scripts/discussion-audit.js:145

      parsed.first = parseIntegerFlag(arg.slice('--first='.length), '--first');
      continue;
    }

    if (arg === '--use-env-github-token') {
      parsed.useEnvGithubToken = true;
      continue;
    }

    if (arg === '--exit-code') {
      parsed.exitCode = true;
      continue;
    }

    throw new Error(`Unknown argument: ${arg}`);
  }

  if (!['text', 'json', 'markdown'].includes(parsed.format)) {
    throw new Error(`Invalid format: ${parsed.format}. Use text, json, or markdown.`);
  }

  if (parsed.writePath && parsed.format === 'text') {
    throw new Error('--write requires --json, --markdown, or --format json|markdown');
  }

  return parsed;
}

function buildReport(options) {
  const repos = options.repos.length > 0 ? options.repos : DEFAULT_REPOS;
  const repoReports = repos.map(repo => {
    try {
      return {
        repo,
        discussions: fetchDiscussionSummary(repo, options),
      };
    } catch (error) {

View on GitHub (pinned to 01e15490f0)

Solutions

  1. Use exactly 'text', 'json', or 'markdown' as the format value
  2. Use the --json or --markdown shortcut flags instead of --format
  3. Remember the value is case-insensitive (lowercased internally) but must be the full word

Example fix

// before
node scripts/discussion-audit.js --format md
node scripts/discussion-audit.js --format xml
// after
node scripts/discussion-audit.js --format markdown
// or
node scripts/discussion-audit.js --markdown
Defensive patterns

Strategy: validation

Validate before calling

// Validate the format value before passing it
const VALID_FORMATS = new Set(['text', 'json', 'markdown']);
const format = (process.env.AUDIT_FORMAT || 'text').toLowerCase();
if (!VALID_FORMATS.has(format)) {
  console.error(`Invalid format: ${format}. Use text, json, or markdown.`);
  process.exit(1);
}

Type guard

// Type guard for a valid output format
function isValidOutputFormat(value) {
  return typeof value === 'string' && ['text', 'json', 'markdown'].includes(value.toLowerCase());
}

Try / catch

try {
  const options = parseArgs(process.argv);
} catch (error) {
  if (error.message.startsWith('Invalid format:')) {
    console.error(error.message);
    console.error('Use --json or --markdown as shortcuts, or --format text|json|markdown');
    process.exit(2);
  }
  throw error;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13). Data as JSON: /api/errors/660d438925e4ac66. Report an issue: GitHub.