pbakaus/impeccable · error · Error
${flag} requires a value.
Error message
${flag} requires a value. What it means
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.
Source
Thrown at scripts/github/sheriff.mjs:765
function splitList(value) {
return String(value || '')
.split(',')
.map((item) => item.trim())
.filter(Boolean);
}
function loginSet(logins) {
return new Set(logins.map(normalizeLogin).filter(Boolean));
}
function normalizeLogin(login) {
return String(login || '').toLowerCase();
}
function requireValue(argv, index, flag) {
const value = argv[index];
if (!value || value.startsWith('--')) throw new Error(`${flag} requires a value.`);
return value;
}
function runGhJson(args) {
const result = runGh(args, { quiet: true });
try {
return JSON.parse(result.stdout || '{}');
} catch (err) {
throw new Error(`Failed to parse gh JSON output: ${err.message}`);
}
}
function runGh(args, options = {}) {
const result = spawnSync('gh', args, {
encoding: 'utf-8',
env: process.env,
});
if (!options.quiet && result.stdout) process.stdout.write(result.stdout);View on GitHub (pinned to d14711ae3d)
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.
Example fix
# before node sheriff.mjs --repo --apply # after node sheriff.mjs --repo owner/name --apply
Defensive patterns
Strategy: validation
Validate before calling
function flagHasValue(argv, flag) {
const idx = argv.indexOf(flag);
if (idx === -1) return true;
const value = argv[idx + 1];
return typeof value === 'string' && value.length > 0 && !value.startsWith('--');
} Type guard
function isFlagValue(value) {
return typeof value === 'string' && value.length > 0 && !value.startsWith('--');
} Try / catch
const value = argv[index];
if (!isFlagValue(value)) {
console.error(`${flag} requires a value.`);
process.exit(2);
} Prevention
- 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.
When it happens
Trigger: Passing `--repo --apply`, `--maintainers` as the last token, or `--warning-days --close-days 5`.
Common situations: Missing value, a reordered command line, or a shell expansion that produced an empty string.
Related errors
- Unknown argument: ${arg}
- --warning-days must be a non-negative number.
- --close-days must be at least --warning-days.
- --now must be a valid date.
- --target requires a path value (use --target <path> or --tar
AI-assisted analysis of pbakaus/impeccable@d14711ae3d (2026-08-13).
Data as JSON: /api/errors/160b1c328892d1a2.
Report an issue: GitHub.