{"record":{"id":"37bb44e15a6403d9","repo":"affaan-m/ECC","slug":"invalid-format-parsed-format-use-text-or-json-37bb44","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/release-video-suite.js","lineNumber":430,"sourceCode":"      continue;\n    }\n\n    if (arg === '--suite-root') {\n      parsed.suiteRoot = path.resolve(readArgValue(args, index, arg));\n      index += 1;\n      continue;\n    }\n\n    if (arg.startsWith('--suite-root=')) {\n      parsed.suiteRoot = path.resolve(arg.slice('--suite-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 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) {\n  if (!text.trim()) {\n    return null;\n  }\n","sourceCodeStart":412,"sourceCodeEnd":448,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/release-video-suite.js#L412-L448","documentation":"Thrown after argument parsing completes if parsed.format is neither 'text' nor 'json'. The script only emits human-readable text or machine-readable JSON, and any other format value is rejected before any work runs.","triggerScenarios":"Passing `--format yaml`, `--format xml`, `--format=md`, or an empty value. The value is lowercased before the check, so case is not the cause.","commonSituations":"Assuming the suite supports a format from a different tool; copy-pasting a format flag from a templating pipeline; fat-fingering the format name.","solutions":["Use `--format text` (default) for human output.","Use `--format json` for machine consumption.","Drop the --format flag entirely to accept the text default.","Verify the format pipeline you intend to consume actually exists upstream."],"exampleFix":"# before\nnode scripts/release-video-suite.js --format yaml\n# after\nnode scripts/release-video-suite.js --format json","handlingStrategy":"validation","validationCode":"const FORMATS = new Set(['text', 'json']);\nconst fmt = (process.argv.find(a => a.startsWith('--format')) || '').split('=')[1] || 'text';\nif (!FORMATS.has(fmt.toLowerCase())) { console.error(`Unsupported format: ${fmt}`); process.exit(2); }","typeGuard":null,"tryCatchPattern":"try { parseArgs(process.argv); } catch (err) { if (err.message.startsWith('Invalid format')) { /* hint at allowed values */ } throw err; }","preventionTips":["Treat the format set as a single source of truth and validate before dispatch.","Default to 'text' when the flag is omitted to avoid accidental invalid values."],"tags":["cli","argument-parsing","format","release-video-suite"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}