{"record":{"id":"65f8d1b1389817bf","repo":"affaan-m/ECC","slug":"flagname-requires-a-value-65f8d1","errorCode":null,"errorMessage":"${flagName} requires a value","messagePattern":"(.+?) requires a value","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/preview-pack-smoke.js","lineNumber":97,"sourceCode":"];\n\nfunction usage() {\n  console.log([\n    'Usage: node scripts/preview-pack-smoke.js [--format <text|json>] [--root <dir>]',\n    '',\n    'Deterministic smoke gate for the ECC 2.0 rc.1 preview pack.',\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 readArgValue(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":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/preview-pack-smoke.js#L79-L115","documentation":"Thrown by readArgValue in preview-pack-smoke's arg parser when a value-taking flag (--format, --root) is followed by nothing or by another `--` flag. Same guard pattern as the other ECC scripts: a missing/flag-like value is rejected so the smoke gate never silently treats a flag name as data. This script is the deterministic smoke gate for the ECC 2.0 rc.1 preview pack.","triggerScenarios":"`--format` as the last token; `--root --format json` (root value missing); a wrapper that conditionally appends a value that resolved empty.","commonSituations":"CI matrix builds the command from templates and a variable was empty; user edited an example and deleted the value.","solutions":["Provide the value right after the flag: `--format json` or `--root /repo`.","Prefer the `=` form for safety: `--format=json`, `--root=/repo`.","Validate any templated value is non-empty before assembling the command."],"exampleFix":"# before\nnode scripts/preview-pack-smoke.js --root --format json\n# after\nnode scripts/preview-pack-smoke.js --root /path/to/repo --format json","handlingStrategy":"validation","validationCode":"function ensurePreviewFlagValue(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}","typeGuard":"function isFlagValueToken(token) {\n  return typeof token === 'string' && token.length > 0 && !token.startsWith('--');\n}","tryCatchPattern":"try {\n  parseArgs(process.argv);\n} catch (err) {\n  if (err.message.endsWith('requires a value')) {\n    console.error(`${err.message}. Use --flag=value form for safety.`);\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Prefer `--format=json` / `--root=/repo` to dodge this entirely.","Assert CI-templated values are non-empty before assembling the command.","This script only accepts --format and --root."],"tags":["cli","argument-validation","preview-pack-smoke"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}