{"record":{"id":"5b203643b6f99418","repo":"affaan-m/ECC","slug":"flagname-requires-a-value-5b2036","errorCode":null,"errorMessage":"${flagName} requires a value","messagePattern":"(.+?) requires a value","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/operator-readiness-dashboard.js","lineNumber":45,"sourceCode":"    '  --write <path>             Write json or markdown output to a file',\n    '  --root <dir>               Repository root to inspect (default: cwd)',\n    '  --repo <owner/repo>        GitHub repo to inspect; repeatable',\n    '  --skip-github              Skip live GitHub queue/discussion checks',\n    '  --max-open-prs <n>         PR budget passed through to platform:audit',\n    '  --max-open-issues <n>      Issue budget passed through to platform:audit',\n    '  --max-dirty-files <n>      Dirty-file budget passed through to platform:audit',\n    '  --allow-untracked <path>   Ignore untracked files under path; repeatable',\n    '  --use-env-github-token     Keep GITHUB_TOKEN when invoking gh',\n    '  --generated-at <iso>       Override generatedAt for deterministic tests',\n    '  --exit-code                Return 2 when the objective is not ready',\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 parseIntegerFlag(value, flagName) {\n  const parsed = Number.parseInt(value, 10);\n  if (!Number.isFinite(parsed) || parsed < 0) {\n    throw new Error(`Invalid ${flagName}: ${value}`);\n  }\n  return parsed;\n}\n\nfunction normalizeRelativePrefix(value) {\n  const normalized = String(value || '')\n    .replace(/\\\\/g, '/')\n    .replace(/^\\.\\/+/, '')\n    .replace(/\\/+$/, '');\n  return normalized ? `${normalized}/` : '';","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/operator-readiness-dashboard.js#L27-L63","documentation":"readValue in operator-readiness-dashboard.js retrieves the value following a value-taking flag (e.g. --format, integer flags). If the next token is missing or starts with '--', it throws this error so a flag is never silently consumed as another flag's value.","triggerScenarios":"Running the dashboard script with a flag like `--port` or `--format` as the last argument, or followed directly by another flag, e.g. `--format --json`; any value flag adjacent to another flag without its value.","commonSituations":"Empty shell variable interpolation before a value; truncated command lines from docs; reordering flags so a value flag ends the command; scripts building argv arrays that drop the value element.","solutions":["Provide the value immediately after the flag.","Reorder flags so value-taking flags are followed by their values.","Guard shell variables: `--port \"${PORT:?PORT not set}\"`.","Check the script's usage output for which flags require values."],"exampleFix":"// before\nnode scripts/operator-readiness-dashboard.js --format\n// after\nnode scripts/operator-readiness-dashboard.js --format json","handlingStrategy":"validation","validationCode":"const VALUE_FLAGS = ['--format','--port','--limit'];\nfor (const f of VALUE_FLAGS) {\n  const i = args.indexOf(f);\n  if (i !== -1 && (!args[i+1] || args[i+1].startsWith('--'))) throw new Error(`${f} needs a value`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  runDashboard(argv);\n} catch (err) {\n  if (err.message.endsWith('requires a value')) {\n    console.error('Provide the value immediately after the flag.');\n  } else throw err;\n}","preventionTips":["Always follow value flags with their value in the same command.","Guard shell variables with ${VAR:?not set}.","Keep value flags away from the end of argv when flags may be appended.","Build command lines programmatically (arrays) instead of string concatenation."],"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"}