{"record":{"id":"9e9b1d0023f901a1","repo":"affaan-m/ECC","slug":"write-requires-a-path","errorCode":null,"errorMessage":"--write requires a path","messagePattern":"--write requires a path","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/ci/supply-chain-advisory-sources.js","lineNumber":391,"sourceCode":"    if (arg === '--help' || arg === '-h') {\n      options.help = true;\n    } else if (arg === '--json') {\n      options.json = true;\n    } else if (arg === '--refresh') {\n      options.refresh = true;\n    } else if (arg === '--strict-refresh') {\n      options.strictRefresh = true;\n      options.refresh = true;\n    } else if (arg === '--generated-at') {\n      options.generatedAt = argv[++i];\n    } else if (arg === '--timeout-ms') {\n      options.timeoutMs = Number(argv[++i]);\n      if (!Number.isFinite(options.timeoutMs) || options.timeoutMs <= 0) {\n        throw new Error('--timeout-ms must be a positive number');\n      }\n    } else if (arg === '--write') {\n      options.writePath = argv[++i];\n      if (!options.writePath) throw new Error('--write requires a path');\n    } else {\n      throw new Error(`Unknown argument: ${arg}`);\n    }\n  }\n  return options;\n}\n\nfunction printHelp() {\n  console.log(`Usage: node scripts/ci/supply-chain-advisory-sources.js [options]\n\nBuild the active supply-chain advisory source report used by the scheduled\nwatch workflow and Linear ITO-57 status updates.\n\nOptions:\n  --json              Emit JSON instead of text\n  --refresh           Check source URLs and record warning status\n  --strict-refresh    Fail when a refreshed source URL returns a warning\n  --generated-at <ts> Override the report timestamp","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/ci/supply-chain-advisory-sources.js#L373-L409","documentation":"The --write flag for scripts/ci/supply-chain-advisory-sources.js expects a file path argument immediately after it. The parser uses argv[++i] to consume the next token, and if that token is undefined (i.e., --write is the last argument on the command line) the script throws this error. This is a hard guard before writeReport() is ever called, ensuring fs.writeFileSync always receives a real path.","triggerScenarios":"Running `node scripts/ci/supply-chain-advisory-sources.js --write` with no path after the flag, or placing --write at the end of the command line. Also triggered if --write is followed by nothing because the shell consumed the next token as a separate command.","commonSituations":"CI YAML or workflow file that appends --write conditionally but forgets the path variable; shell scripts that build the argument list dynamically and skip the path; copy-pasting a partial command from documentation without completing the path.","solutions":["Provide a file path immediately after --write, e.g. --write reports/advisory-sources.json","If building the command dynamically, ensure the path variable is non-empty before appending --write","Run the script with --help to see all expected flag-value pairs"],"exampleFix":"// before\nnode scripts/ci/supply-chain-advisory-sources.js --write\n// after\nnode scripts/ci/supply-chain-advisory-sources.js --write reports/advisory-sources.json","handlingStrategy":"validation","validationCode":"// Before calling parseArgs, validate that --write has a companion path\nconst argv = process.argv.slice(2);\nconst writeIdx = argv.indexOf('--write');\nif (writeIdx !== -1 && (!argv[writeIdx + 1] || argv[writeIdx + 1].startsWith('--'))) {\n  console.error('Error: --write requires a file path argument');\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":"// Wrap the script invocation and catch argument errors with user-friendly messages\ntry {\n  const options = parseArgs(process.argv.slice(2));\n} catch (error) {\n  if (error.message.includes('requires a path')) {\n    console.error('Missing file path for --write. Usage: --write <file-path>');\n    printHelp();\n    process.exit(2);\n  }\n  throw error;\n}","preventionTips":["Always provide a file path immediately after --write in the same command","In CI YAML, use a named variable for the path and verify it is non-empty before appending --write","Run the script with --help first to confirm expected flag-value pairs"],"tags":["cli","argument-parsing","supply-chain","ci"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}