affaan-m/ECC · error · Error

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

Error message

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

What it means

Thrown by parseArgs in scripts/observability-readiness.js after the flag loop completes, when the accumulated --format value is neither 'text' nor 'json'. The value is lowercased during parsing, so case differences are tolerated, but any other string is rejected.

Source

Thrown at scripts/observability-readiness.js:72

      continue;
    }

    if (arg === '--root') {
      parsed.root = path.resolve(readValue(args, index, arg));
      index += 1;
      continue;
    }

    if (arg.startsWith('--root=')) {
      parsed.root = path.resolve(arg.slice('--root='.length));
      continue;
    }

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

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

  return parsed;
}

function fileExists(rootDir, relativePath) {
  return fs.existsSync(path.join(rootDir, relativePath));
}

function readText(rootDir, relativePath) {
  try {
    return fs.readFileSync(path.join(rootDir, relativePath), 'utf8');
  } catch (_error) {
    return '';
  }
}

function safeParseJson(text) {

View on GitHub (pinned to 01e15490f0)

Solutions

  1. Use one of the two supported values: `--format text` or `--format json`.
  2. If you omit --format entirely it defaults to text, so dropping the flag is also valid.
  3. If you need markdown output, use operator-readiness-dashboard.js which supports it.

Example fix

// before
node scripts/observability-readiness.js --format markdown
// after
node scripts/observability-readiness.js --format json
Defensive patterns

Strategy: validation

Validate before calling

const OBS_FORMATS = new Set(['text', 'json']);
function normalizeObsFormat(raw) {
  const f = String(raw || '').toLowerCase();
  if (!OBS_FORMATS.has(f)) throw new Error(`Unsupported format '${raw}'. Use text or json.`);
  return f;
}

Type guard

function isObsFormat(value) {
  return typeof value === 'string' && OBS_FORMATS.has(value.toLowerCase());
}

Prevention

When it happens

Trigger: Passing `--format yaml`, `--format markdown` (markdown is supported by the sibling dashboard script, not here), or `--format JSON5`. An empty value (`--format=`) lowercases to '' and also triggers this.

Common situations: Assuming this script shares the dashboard's format options; passing an empty string via a shell variable; upstream tooling that defaults to a format like 'junit' or 'html'.

Related errors


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