pbakaus/impeccable · error · Error

--close-days must be at least --warning-days.

Error message

--close-days must be at least --warning-days.

What it means

Thrown by sheriff.mjs parseArgs when --close-days is not a finite number or is less than --warning-days. The close threshold must come at or after the warning threshold or the warning phase could be skipped entirely.

Source

Thrown at scripts/github/sheriff.mjs:453

    else if (arg === '--warning-days') options.warningDays = Number(requireValue(argv, ++i, arg));
    else if (arg === '--close-days') options.closeDays = Number(requireValue(argv, ++i, arg));
    else if (arg === '--maintainers') options.maintainers = splitList(requireValue(argv, ++i, arg));
    else if (arg === '--regular-contributors') options.regularContributors = splitList(requireValue(argv, ++i, arg));
    else if (arg === '--exempt-labels') options.exemptLabels = splitList(requireValue(argv, ++i, arg));
    else if (arg === '--now') options.now = new Date(requireValue(argv, ++i, arg));
    else if (arg === '--help' || arg === '-h') {
      printHelp();
      process.exit(0);
    } else {
      throw new Error(`Unknown argument: ${arg}`);
    }
  }

  if (!Number.isFinite(options.warningDays) || options.warningDays < 0) {
    throw new Error('--warning-days must be a non-negative number.');
  }
  if (!Number.isFinite(options.closeDays) || options.closeDays < options.warningDays) {
    throw new Error('--close-days must be at least --warning-days.');
  }
  if (Number.isNaN(options.now.getTime())) throw new Error('--now must be a valid date.');

  return options;
}

function latestMaintainerWaitCommand(pr, maintainers) {
  return latestDate([
    ...(pr.comments || [])
      .filter((comment) => maintainers.has(normalizeLogin(comment.authorLogin)))
      .filter((comment) => hasSheriffWaitCommand(comment.body))
      .map((comment) => comment.createdAt),
    ...(pr.reviews || [])
      .filter((review) => maintainers.has(normalizeLogin(review.authorLogin)))
      .filter((review) => hasSheriffWaitCommand(review.body))
      .map((review) => review.submittedAt),
  ]);
}

View on GitHub (pinned to d14711ae3d)

Solutions

  1. Ensure close-days >= warning-days, e.g. `--warning-days 7 --close-days 14`.
  2. If you want a shorter close window, lower warning-days to match.
  3. Double-check the order of the two flags in your wrapper.

Example fix

# before
node sheriff.mjs --warning-days 10 --close-days 5

# after
node sheriff.mjs --warning-days 5 --close-days 10
Defensive patterns

Strategy: validation

Validate before calling

function isValidDayPair(warningDays, closeDays) {
  const w = Number(warningDays), c = Number(closeDays);
  return Number.isFinite(w) && Number.isFinite(c) && w >= 0 && c >= w;
}

Type guard

function isOrderedDayPair(warningDays, closeDays) {
  const w = Number(warningDays), c = Number(closeDays);
  return Number.isFinite(w) && Number.isFinite(c) && w >= 0 && c >= w;
}

Try / catch

if (!isOrderedDayPair(warningDays, closeDays)) {
  console.error('--close-days must be at least --warning-days.');
  process.exit(2);
}

Prevention

When it happens

Trigger: Passing `--warning-days 10 --close-days 5`, a non-numeric close-days, or a close-days smaller than the warning window.

Common situations: Swapping the two flags by mistake, or lowering close-days without adjusting warning-days.

Related errors


AI-assisted analysis of pbakaus/impeccable@d14711ae3d (2026-08-13). Data as JSON: /api/errors/354243d5a2e8c9f5. Report an issue: GitHub.