{"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":"exception","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/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/observability-readiness.js#L7-L43","documentation":"Thrown by readValue in scripts/observability-readiness.js when a value-taking flag (`--format`, `--root`) is the last token or is immediately followed by another flag (a token starting with `--`). The CLI parses flags manually and treats a missing or flag-like next token as 'no value supplied'.","triggerScenarios":"Running `node scripts/observability-readiness.js --format` at end of line, or `--format --root .` where `--format` is followed by another flag. Only the space-separated forms (`--format text`) go through readValue; the `--format=text` equals-form parses inline and never hits this.","commonSituations":"Truncated command lines from copy-paste; a shell variable for the value that expanded to empty; ordering flags such that a value-taking flag ends up adjacent to the next flag.","solutions":["Supply the value right after the flag: `--format json`.","Use the equals form to avoid the adjacency problem: `--format=json`.","Quote shell variables so an empty expansion is visible and you can detect it before invocation."],"exampleFix":"// before\nnode scripts/observability-readiness.js --format --root .\n// after\nnode scripts/observability-readiness.js --format json --root .","handlingStrategy":"validation","validationCode":"function pairFlagsAndValues(argv) {\n  const valueFlags = new Set(['--format', '--root']);\n  for (let i = 0; i < argv.length; i++) {\n    if (valueFlags.has(argv[i])) {\n      const next = argv[i + 1];\n      if (!next || next.startsWith('--')) {\n        throw new Error(`${argv[i]} needs a value; pass '--${argv[i].slice(2)}=value' or add the value`);\n      }\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer the equals form (`--format=json`) in generated command lines — it cannot hit the missing-value path.","Validate that variables expanding into flag values are non-empty before building the argv.","Keep value-taking flags away from the end of the command line."],"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"}