{"record":{"id":"957846220520e620","repo":"koala73/worldmonitor","slug":"unknown-argument-args-index","errorCode":null,"errorMessage":"Unknown argument: ${args[index]}","messagePattern":"Unknown argument: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/mcp-live-smoke.mjs","lineNumber":814,"sourceCode":"\n  checks += 1;\n  try {\n    const { res } = await timedFetch(`${host}/mcp`, { method: 'OPTIONS' }, { group: 'aliases' });\n    if (res.status !== 204) {\n      fail(host, 'OPTIONS /mcp CORS', `expected 204, got ${res.status}`);\n    } else {\n      ok(host, 'OPTIONS /mcp CORS', '204');\n    }\n  } catch (err) {\n    throwIfRunBudgetExhausted(err);\n    fail(host, 'OPTIONS /mcp CORS', `HANG/transport error: ${formatSafeError(err)}`);\n  }\n}\n\nfunction reportPathFromArgs(args) {\n  let reportPath = null;\n  for (let index = 0; index < args.length; index += 1) {\n    if (args[index] !== '--report') throw new Error(`Unknown argument: ${args[index]}`);\n    if (reportPath !== null || !args[index + 1]) throw new Error('--report requires exactly one path');\n    reportPath = args[index + 1];\n    index += 1;\n  }\n  return reportPath;\n}\n\nfunction checkedOutSha() {\n  try {\n    return execFileSync('git', ['rev-parse', 'HEAD'], { encoding: 'utf8' }).trim();\n  } catch {\n    return null;\n  }\n}\n\nfunction writeReport(reportPath, completedAllGroups) {\n  if (!reportPath) return true;\n  const report = {","sourceCodeStart":796,"sourceCodeEnd":832,"githubUrl":"https://github.com/koala73/worldmonitor/blob/e586b8b4b80f595aa7ece295eec10d76f2921240/scripts/mcp-live-smoke.mjs#L796-L832","documentation":"reportPathFromArgs() accepts exactly one CLI flag form: --report <path>. Any argument that is not the literal '--report' throws 'Unknown argument: <arg>'. This is a strict allow-list parser so typos and unsupported flags fail loudly instead of being silently ignored.","triggerScenarios":"Running node scripts/mcp-live-smoke.mjs --output ./report.json (wrong flag name), a positional argument like a host name, or a mistyped flag such as --report=./x.json (parsed as one token).","commonSituations":"Developers copying flags from other smoke/merge scripts (e.g. --file or --execute from merge-train.mjs), typos like --repport, or passing extra positional args after the flag pair.","solutions":["Use --report <path> to supply the report location","Remove any unexpected positional or extra arguments from the command line","Check the script's usage docs for the supported flag set","Fix the flag spelling (e.g. --repport -> --report)"],"exampleFix":"// before\nnode scripts/mcp-live-smoke.mjs --out report.json\n// after\nnode scripts/mcp-live-smoke.mjs --report report.json","handlingStrategy":"validation","validationCode":"const ALLOWED = new Set(['--report']);\nfor (const a of process.argv.slice(2)) {\n  if (a !== '--report' && !ALLOWED.has(a)) throw new Error(`Unknown argument: ${a}`);\n}","typeGuard":"null","tryCatchPattern":"try {\n  const reportPath = reportPathFromArgs(process.argv.slice(2));\n} catch (err) {\n  if (err.message.startsWith('Unknown argument')) console.error(`Usage: --report <path>. ${err.message}`);\n  process.exit(2);\n}","preventionTips":["Only pass --report <path> to mcp-live-smoke.mjs","Double-check flag spelling when copying commands from other scripts","Read the script's usage docs before adding flags"],"tags":["cli","arguments","smoke-test"],"backgroundTag":"invalid-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"}