{"record":{"id":"08b5d8f2e0edaf4d","repo":"affaan-m/ECC","slug":"invalid-format-parsed-format-use-text-or-json-08b5d8","errorCode":null,"errorMessage":"Invalid format: ${parsed.format}. Use text or json.","messagePattern":"Invalid format: (.+?)\\. Use text or json\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/observability-readiness.js","lineNumber":72,"sourceCode":"      continue;\n    }\n\n    if (arg === '--root') {\n      parsed.root = path.resolve(readValue(args, index, arg));\n      index += 1;\n      continue;\n    }\n\n    if (arg.startsWith('--root=')) {\n      parsed.root = path.resolve(arg.slice('--root='.length));\n      continue;\n    }\n\n    throw new Error(`Unknown argument: ${arg}`);\n  }\n\n  if (!['text', 'json'].includes(parsed.format)) {\n    throw new Error(`Invalid format: ${parsed.format}. Use text or json.`);\n  }\n\n  return parsed;\n}\n\nfunction fileExists(rootDir, relativePath) {\n  return fs.existsSync(path.join(rootDir, relativePath));\n}\n\nfunction readText(rootDir, relativePath) {\n  try {\n    return fs.readFileSync(path.join(rootDir, relativePath), 'utf8');\n  } catch (_error) {\n    return '';\n  }\n}\n\nfunction safeParseJson(text) {","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/observability-readiness.js#L54-L90","documentation":"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.","triggerScenarios":"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.","commonSituations":"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'.","solutions":["Use one of the two supported values: `--format text` or `--format json`.","If you omit --format entirely it defaults to text, so dropping the flag is also valid.","If you need markdown output, use operator-readiness-dashboard.js which supports it."],"exampleFix":"// before\nnode scripts/observability-readiness.js --format markdown\n// after\nnode scripts/observability-readiness.js --format json","handlingStrategy":"validation","validationCode":"const OBS_FORMATS = new Set(['text', 'json']);\nfunction normalizeObsFormat(raw) {\n  const f = String(raw || '').toLowerCase();\n  if (!OBS_FORMATS.has(f)) throw new Error(`Unsupported format '${raw}'. Use text or json.`);\n  return f;\n}","typeGuard":"function isObsFormat(value) {\n  return typeof value === 'string' && OBS_FORMATS.has(value.toLowerCase());\n}","tryCatchPattern":null,"preventionTips":["Default to omitting --format (text) unless you specifically need JSON for parsing.","Lowercase and validate the format upstream before passing it through.","Remember markdown is supported only by operator-readiness-dashboard.js."],"tags":["cli","observability","argument-validation"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}