{"record":{"id":"accbc46fc8d2f910","repo":"affaan-m/ECC","slug":"unknown-argument-arg-accbc4","errorCode":null,"errorMessage":"Unknown argument: ${arg}","messagePattern":"Unknown argument: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/ci/supply-chain-advisory-sources.js","lineNumber":393,"sourceCode":"    } 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\n  --timeout-ms <n>    Per-source refresh timeout (default: ${DEFAULT_TIMEOUT_MS})\n  --write <path>      Write the report to a file","sourceCodeStart":375,"sourceCodeEnd":411,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/ci/supply-chain-advisory-sources.js#L375-L411","documentation":"The argument parser in supply-chain-advisory-sources.js only recognizes a fixed set of flags: --help, -h, --json, --refresh, --strict-refresh, --generated-at, --timeout-ms, and --write. Any token that does not match one of these falls through to the else branch and throws. This is a strict fail-fast parser design — no positional arguments or unknown flags are tolerated.","triggerScenarios":"Passing a flag from a different script by mistake (e.g. --output instead of --write), using a removed flag from an older version, or a typo such as --stric-refresh instead of --strict-refresh. Also triggered by passing positional arguments since the parser expects only flags.","commonSituations":"Upgrading the script to a new version that renamed or removed flags; CI workflows with stale argument lists; copy-pasting commands from outdated documentation or blog posts.","solutions":["Run the script with --help to list all accepted flags and compare against what you passed","Check for typos in flag names (e.g. --strict-refresh vs --stric-refresh)","If migrating from an older version, consult the changelog or printHelp() output for renamed flags"],"exampleFix":"// before\nnode scripts/ci/supply-chain-advisory-sources.js --output report.json\n// after\nnode scripts/ci/supply-chain-advisory-sources.js --write report.json","handlingStrategy":"validation","validationCode":"// Pre-validate all arguments against the accepted set before invoking parseArgs\nconst ACCEPTED = new Set(['--help', '-h', '--json', '--refresh', '--strict-refresh', '--generated-at', '--timeout-ms', '--write']);\nconst argv = process.argv.slice(2);\nfor (let i = 0; i < argv.length; i++) {\n  const arg = argv[i];\n  if (!ACCEPTED.has(arg) && !arg.startsWith('-')) continue; // positional args are not expected but skip non-flag tokens\n  if (!ACCEPTED.has(arg) && arg.startsWith('-')) {\n    console.error(`Unknown argument: ${arg}`);\n    printHelp();\n    process.exit(1);\n  }\n}","typeGuard":null,"tryCatchPattern":"// Catch unknown-argument errors and show help\ntry {\n  const options = parseArgs(process.argv.slice(2));\n} catch (error) {\n  if (error.message.startsWith('Unknown argument:')) {\n    console.error(error.message);\n    printHelp();\n    process.exit(2);\n  }\n  throw error;\n}","preventionTips":["Run the script with --help to discover accepted flags before constructing commands","When upgrading ECC versions, re-check the help output for renamed or removed flags","In CI, pin the ECC version and document the exact flags used in comments"],"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"}