{"record":{"id":"afc0d59b314af08c","repo":"koala73/worldmonitor","slug":"report-requires-exactly-one-path","errorCode":null,"errorMessage":"--report requires exactly one path","messagePattern":"--report requires exactly one path","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/mcp-live-smoke.mjs","lineNumber":815,"sourceCode":"  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 = {\n    version: 'mcp_live_smoke_report/v1',","sourceCodeStart":797,"sourceCodeEnd":833,"githubUrl":"https://github.com/koala73/worldmonitor/blob/e586b8b4b80f595aa7ece295eec10d76f2921240/scripts/mcp-live-smoke.mjs#L797-L833","documentation":"reportPathFromArgs() validates that '--report' appears exactly once and is followed by exactly one non-empty path value. If it's repeated or followed by nothing (end of args) or an empty string, it throws '--report requires exactly one path'.","triggerScenarios":"Calling the script with --report and no value (last argument), with --report followed by another flag starting with '--', or with --report given twice (second occurrence sees reportPath !== null).","commonSituations":"Shell variable expansion producing an empty value ($REPORT_PATH unset), copy-paste duplicating the flag, or forgetting the path argument entirely.","solutions":["Supply exactly one path: --report ./mcp-smoke-report.json","Ensure the value is not empty — check that any shell variable holding it is set","Remove duplicate --report flags, keeping only one"],"exampleFix":"// before\nnode scripts/mcp-live-smoke.mjs --report\n// after\nnode scripts/mcp-live-smoke.mjs --report ./mcp-smoke-report.json","handlingStrategy":"validation","validationCode":"const idx = args.indexOf('--report');\nif (idx !== -1 && (!args[idx + 1] || args[idx + 1].startsWith('--'))) throw new Error('--report requires exactly one path');","typeGuard":"null","tryCatchPattern":"try {\n  const reportPath = reportPathFromArgs(process.argv.slice(2));\n} catch (err) {\n  if (err.message.includes('--report')) console.error('Provide exactly one: --report <path>');\n  process.exit(2);\n}","preventionTips":["Always pass a non-empty path immediately after --report","Ensure shell variables holding the path are set (quote them: --report \"$REPORT_PATH\")","Pass --report only once per invocation"],"tags":["cli","arguments","smoke-test"],"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"}