{"record":{"id":"5ef5d59bdb0ae03e","repo":"affaan-m/ECC","slug":"flagname-requires-a-value-5ef5d5","errorCode":null,"errorMessage":"${flagName} requires a value","messagePattern":"(.+?) requires a value","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/platform-audit.js","lineNumber":53,"sourceCode":"    '  --markdown                 Alias for --format markdown',\n    '  --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>         Fail when open PR count is above n (default: 20)',\n    '  --max-open-issues <n>      Fail when open issue count is above n (default: 20)',\n    '  --max-dirty-files <n>      Fail when blocking dirty file count is above n (default: 0)',\n    '  --allow-untracked <path>   Ignore untracked files under path; repeatable',\n    '  --use-env-github-token     Keep GITHUB_TOKEN when invoking gh',\n    '  --exit-code                Return 2 when the audit 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 parseArgs(argv) {\n  const args = argv.slice(2);\n  const parsed = {\n    allowUntracked: [],\n    exitCode: false,\n    format: 'text',","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/platform-audit.js#L35-L71","documentation":"Thrown by readValue in platform-audit's arg parser when a flag that expects a value is either the last token on the line or is immediately followed by another `--` flag. It guards every value-taking option (--format, --root, --repo, --allow-untracked, --write, --max-open-prs, --max-open-issues, --max-dirty-files) so parseArgs never silently treats a flag name as a value.","triggerScenarios":"Trailing flag with no value: `--format` at end of line; value that is itself a flag like `--root --repo x`; copy-paste that dropped the value; shell quoting that swallowed the value leaving the next flag adjacent.","commonSituations":"User edits a CI invocation and deletes a value; env var expansion produced empty between two flags; alias/wrapper script concatenates args incorrectly.","solutions":["Supply the value immediately after the flag: `--format json`.","Use the `=` form which cannot trigger this: `--format=json`, `--root=/repo`.","Check that any shell variable used as a value is non-empty and quoted."],"exampleFix":"# before\nnode scripts/platform-audit.js --root --repo owner/repo\n# after\nnode scripts/platform-audit.js --root /path/to/repo --repo owner/repo\n# or\nnode scripts/platform-audit.js --root=/path/to/repo --repo=owner/repo","handlingStrategy":"validation","validationCode":"// Validate a flag/value pair before the parser sees it\nfunction ensureFlagHasValue(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 isFlagValue(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}. Tip: use --flag=value form.`);\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Prefer the `--flag=value` form, which cannot produce this error.","Quote shell variables used as values and assert they are non-empty.","Validate assembled command strings in CI before executing them."],"tags":["cli","argument-validation","platform-audit"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}