{"record":{"id":"a1e38b924ce6fd9f","repo":"koala73/worldmonitor","slug":"no-pr-numbers-given","errorCode":null,"errorMessage":"No PR numbers given","messagePattern":"No PR numbers given","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/merge-train.mjs","lineNumber":242,"sourceCode":"\nexport function parseArgs(argv) {\n  const numbers = [];\n  let execute = false;\n  let file = null;\n  for (let index = 0; index < argv.length; index += 1) {\n    const arg = argv[index];\n    if (arg === '--execute') { execute = true; continue; }\n    if (arg === '--file') { file = argv[index + 1]; index += 1; continue; }\n    if (/^\\d+$/.test(arg)) { numbers.push(Number(arg)); continue; }\n    throw new Error(`Unrecognised argument: ${arg}`);\n  }\n  if (file) {\n    for (const line of readFileSync(file, 'utf8').split('\\n')) {\n      const match = line.trim().match(/^#?(\\d+)$/);\n      if (match) numbers.push(Number(match[1]));\n    }\n  }\n  if (numbers.length === 0) throw new Error('No PR numbers given');\n  return { queue: [...new Set(numbers)], execute };\n}\n\nconst USAGE = `usage: node scripts/merge-train.mjs <pr>... [--file <path>] [--execute]\n\nRe-evaluates the Deploy Gate for each PR's exact head immediately before\nmerging it, so no PR merges on a verdict that predates the previous merge.\nWithout --execute it only reports what it would do.`;\n\nif (isMainModule(import.meta.url, process.argv[1])) {\n  let parsed;\n  try {\n    parsed = parseArgs(process.argv.slice(2));\n  } catch (error) {\n    console.error(`merge-train: ${error.message}\\n\\n${USAGE}`);\n    process.exit(2);\n  }\n  const { queue, execute } = parsed;","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/koala73/worldmonitor/blob/e586b8b4b80f595aa7ece295eec10d76f2921240/scripts/merge-train.mjs#L224-L260","documentation":"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.","triggerScenarios":"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).","commonSituations":"An empty or wrongly formatted PR list file, forgetting positional numbers, or a file path that resolves to an empty/different file than expected.","solutions":["Pass at least one PR number: node scripts/merge-train.mjs 123","Check the --file contents contain lines matching an optional # followed by digits (e.g. '123' or '#123')","Verify the file path passed to --file is the intended, non-empty list"],"exampleFix":"// before\nnode scripts/merge-train.mjs --file prs.txt   # prs.txt has only comments\n// after\nnode scripts/merge-train.mjs --file prs.txt   # with lines like \"123\" or \"#123\"","handlingStrategy":"validation","validationCode":"const args = process.argv.slice(2).filter(a => /^#?\\d+$/.test(a));\nif (args.length === 0 && !process.argv.includes('--file')) throw new Error('No PR numbers given');","typeGuard":"null","tryCatchPattern":"try {\n  const { queue, execute } = parseArgs(process.argv.slice(2));\n} catch (err) {\n  if (err.message === 'No PR numbers given') console.error(`${err.message}\\n${USAGE}`);\n  process.exit(2);\n}","preventionTips":["Always include at least one PR number argument or a populated --file","Check the PR list file for blank/comment-only content before running","Verify the --file path points to the intended list"],"tags":["cli","arguments","git"],"backgroundTag":"missing-cli-argument","analyzedSha":"e586b8b4b80f595aa7ece295eec10d76f2921240","analyzedAt":"2026-09-22T01:50:49.965Z","contentChangedAt":"2026-09-22T01:50:49.965Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}