{"record":{"id":"160b1c328892d1a2","repo":"pbakaus/impeccable","slug":"flag-requires-a-value","errorCode":null,"errorMessage":"${flag} requires a value.","messagePattern":"(.+?) requires a value\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/github/sheriff.mjs","lineNumber":765,"sourceCode":"\nfunction splitList(value) {\n  return String(value || '')\n    .split(',')\n    .map((item) => item.trim())\n    .filter(Boolean);\n}\n\nfunction loginSet(logins) {\n  return new Set(logins.map(normalizeLogin).filter(Boolean));\n}\n\nfunction normalizeLogin(login) {\n  return String(login || '').toLowerCase();\n}\n\nfunction requireValue(argv, index, flag) {\n  const value = argv[index];\n  if (!value || value.startsWith('--')) throw new Error(`${flag} requires a value.`);\n  return value;\n}\n\nfunction runGhJson(args) {\n  const result = runGh(args, { quiet: true });\n  try {\n    return JSON.parse(result.stdout || '{}');\n  } catch (err) {\n    throw new Error(`Failed to parse gh JSON output: ${err.message}`);\n  }\n}\n\nfunction runGh(args, options = {}) {\n  const result = spawnSync('gh', args, {\n    encoding: 'utf-8',\n    env: process.env,\n  });\n  if (!options.quiet && result.stdout) process.stdout.write(result.stdout);","sourceCodeStart":747,"sourceCodeEnd":783,"githubUrl":"https://github.com/pbakaus/impeccable/blob/d14711ae3d1a1dd62dee61a358d27f107c51ccd0/scripts/github/sheriff.mjs#L747-L783","documentation":"Thrown by sheriff.mjs requireValue helper when a value-expecting flag (--repo, --warning-days, etc.) is either missing its value or the next token looks like another flag (starts with --). It guards against a value accidentally consuming the following flag.","triggerScenarios":"Passing `--repo --apply`, `--maintainers` as the last token, or `--warning-days --close-days 5`.","commonSituations":"Missing value, a reordered command line, or a shell expansion that produced an empty string.","solutions":["Provide a concrete value immediately after the flag: `--repo owner/name`.","Reorder so value-flags are not adjacent to other flags without their value.","If the value may be empty in automation, guard and omit the flag entirely."],"exampleFix":"# before\nnode sheriff.mjs --repo --apply\n\n# after\nnode sheriff.mjs --repo owner/name --apply","handlingStrategy":"validation","validationCode":"function flagHasValue(argv, flag) {\n  const idx = argv.indexOf(flag);\n  if (idx === -1) return true;\n  const value = argv[idx + 1];\n  return typeof value === 'string' && value.length > 0 && !value.startsWith('--');\n}","typeGuard":"function isFlagValue(value) {\n  return typeof value === 'string' && value.length > 0 && !value.startsWith('--');\n}","tryCatchPattern":"const value = argv[index];\nif (!isFlagValue(value)) {\n  console.error(`${flag} requires a value.`);\n  process.exit(2);\n}","preventionTips":["Place value-flags and their values adjacently in command lines.","Avoid optional flags that may resolve to an empty value in automation.","Validate the full argv shape (each value-flag has a non-flag follower) before running sheriff."],"tags":["cli","sheriff","argv","validation"],"backgroundTag":null,"analyzedSha":"d14711ae3d1a1dd62dee61a358d27f107c51ccd0","analyzedAt":"2026-08-13T00:52:25.771Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}