{"record":{"id":"b9f744cb082df292","repo":"affaan-m/ECC","slug":"flagname-requires-a-value-b9f744","errorCode":null,"errorMessage":"${flagName} requires a value","messagePattern":"(.+?) requires a value","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/observability-readiness.js","lineNumber":25,"sourceCode":"const RUBRIC_VERSION = '2026-05-11';\n\nfunction usage() {\n  console.log([\n    'Usage: node scripts/observability-readiness.js [--format <text|json>] [--root <dir>]',\n    '',\n    'Deterministic ECC 2.0 observability readiness gate.',\n    '',\n    'Options:',\n    '  --format <text|json>  Output format (default: text)',\n    '  --root <dir>          Repository root to inspect (default: cwd)',\n    '  --help, -h            Show this help'\n  ].join('\\n'));\n}\n\nfunction readValue(args, index, flagName) {\n  const value = args[index + 1];\n  if (!value || value.startsWith('--')) {\n    throw new Error(`${flagName} requires a value`);\n  }\n  return value;\n}\n\nfunction parseArgs(argv) {\n  const args = argv.slice(2);\n  const parsed = {\n    format: 'text',\n    help: false,\n    root: path.resolve(process.cwd())\n  };\n\n  for (let index = 0; index < args.length; index += 1) {\n    const arg = args[index];\n\n    if (arg === '--help' || arg === '-h') {\n      parsed.help = true;\n      continue;","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/observability-readiness.js#L7-L43","documentation":"readValue in observability-readiness.js fetches the value following a value-taking flag (e.g. --root, --format). If the next token is absent or looks like another flag (starts with '--'), it throws this error rather than silently consuming a flag as a value.","triggerScenarios":"Running the script with `--format` as the last argument, or `--format --json` where the value slot is filled by another flag; any value-bearing flag immediately followed by another flag or end of argv.","commonSituations":"Shell variables expanding to empty strings before a flag value; copy-paste dropping the value; reordering CLI flags so a value flag sits last; empty config variable interpolation like `--root $ROOT` with ROOT unset.","solutions":["Supply the value directly after the flag: `--format json`, `--root ./docs`.","Reorder arguments so value-taking flags are followed by their values, not other flags.","Guard shell variables: `--root \"${ROOT:?ROOT not set}\"`.","For --format, use the literal values text or json."],"exampleFix":"// before\nnode scripts/observability-readiness.js --format --json\n// after\nnode scripts/observability-readiness.js --format json","handlingStrategy":"validation","validationCode":"const i = args.indexOf('--format');\nif (i !== -1 && (!args[i+1] || args[i+1].startsWith('--'))) throw new Error('--format needs a value immediately after it');","typeGuard":null,"tryCatchPattern":"try {\n  runObservability(argv);\n} catch (err) {\n  if (err.message.endsWith('requires a value')) {\n    console.error('Provide the flag value immediately after the flag name.');\n  } else throw err;\n}","preventionTips":["Place values immediately after value-taking flags.","Don't place value flags at the end of the command line.","Use \"${VAR:?not set}\" guards for interpolated values.","Prefer the = syntax (e.g. --root=docs) where supported to bind value and flag."],"tags":["cli","missing-argument","parsing"],"backgroundTag":"missing-cli-argument","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}