koala73/worldmonitor · error

No PR numbers given

Error message

No PR numbers given

What it means

parseArgs() requires at least one PR number after argument parsing (from positional numbers and/or the --file list). If none were collected it throws 'No PR numbers given', since re-evaluating the Deploy Gate for an empty queue is meaningless.

Solutions

  1. Pass at least one PR number: node scripts/merge-train.mjs 123
  2. Check the --file contents contain lines matching an optional # followed by digits (e.g. '123' or '#123')
  3. Verify the file path passed to --file is the intended, non-empty list

Example fix

// before
node scripts/merge-train.mjs --file prs.txt   # prs.txt has only comments
// after
node scripts/merge-train.mjs --file prs.txt   # with lines like "123" or "#123"
Defensive patterns

Strategy: validation

Validate before calling

const args = process.argv.slice(2).filter(a => /^#?\d+$/.test(a));
if (args.length === 0 && !process.argv.includes('--file')) throw new Error('No PR numbers given');

Type guard

null

Try / catch

try {
  const { queue, execute } = parseArgs(process.argv.slice(2));
} catch (err) {
  if (err.message === 'No PR numbers given') console.error(`${err.message}\n${USAGE}`);
  process.exit(2);
}

Prevention

When it happens

Trigger: Running node scripts/merge-train.mjs with no arguments; running with --execute only; running with --file pointing at a file whose lines contain no numeric PR numbers (comments, blank lines, or prose only).

Common situations: An empty or wrongly formatted PR list file, forgetting positional numbers, or a file path that resolves to an empty/different file than expected.

Understand the failure class

Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.

Related errors


AI-assisted analysis of koala73/worldmonitor@e586b8b4b8 (2026-09-22). Data as JSON: /api/errors/a1e38b924ce6fd9f. Report an issue: GitHub.

Appendix: source

Thrown at scripts/merge-train.mjs:242

export function parseArgs(argv) {
  const numbers = [];
  let execute = false;
  let file = null;
  for (let index = 0; index < argv.length; index += 1) {
    const arg = argv[index];
    if (arg === '--execute') { execute = true; continue; }
    if (arg === '--file') { file = argv[index + 1]; index += 1; continue; }
    if (/^\d+$/.test(arg)) { numbers.push(Number(arg)); continue; }
    throw new Error(`Unrecognised argument: ${arg}`);
  }
  if (file) {
    for (const line of readFileSync(file, 'utf8').split('\n')) {
      const match = line.trim().match(/^#?(\d+)$/);
      if (match) numbers.push(Number(match[1]));
    }
  }
  if (numbers.length === 0) throw new Error('No PR numbers given');
  return { queue: [...new Set(numbers)], execute };
}

const USAGE = `usage: node scripts/merge-train.mjs <pr>... [--file <path>] [--execute]

Re-evaluates the Deploy Gate for each PR's exact head immediately before
merging it, so no PR merges on a verdict that predates the previous merge.
Without --execute it only reports what it would do.`;

if (isMainModule(import.meta.url, process.argv[1])) {
  let parsed;
  try {
    parsed = parseArgs(process.argv.slice(2));
  } catch (error) {
    console.error(`merge-train: ${error.message}\n\n${USAGE}`);
    process.exit(2);
  }
  const { queue, execute } = parsed;

View on GitHub (pinned to e586b8b4b8)