{"record":{"id":"6c2bce262c2cf45a","repo":"JuliusBrussee/caveman","slug":"unknown-argument-arg","errorCode":null,"errorMessage":"unknown argument ${arg}","messagePattern":"unknown argument (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/build-release-binaries.mjs","lineNumber":52,"sourceCode":"  return targets.flatMap(([goos, arch]) =>\n    RELEASE_BINARIES.map(([name]) => releaseArtifactName(name, goos, arch)));\n}\n\nfunction parseArgs(argv) {\n  let out = resolve(root, \"dist\", \"binaries\");\n  const targets = [];\n  for (let index = 0; index < argv.length; index++) {\n    const arg = argv[index];\n    if (arg === \"--out\") out = resolve(argv[++index] ?? \"\");\n    else if (arg === \"--target\") {\n      const value = argv[++index] ?? \"\";\n      const [goos, arch] = value.split(\"/\");\n      if (!RELEASE_TARGETS.some(([knownOS, knownArch]) => knownOS === goos && knownArch === arch)) {\n        throw new Error(`unsupported release target ${JSON.stringify(value)}`);\n      }\n      targets.push([goos, arch]);\n    } else if (arg === \"--list\") return { out, targets: RELEASE_TARGETS, list: true };\n    else throw new Error(`unknown argument ${arg}`);\n  }\n  return { out, targets: targets.length ? targets : RELEASE_TARGETS, list: false };\n}\n\nfunction build({ out, targets }) {\n  mkdirSync(out, { recursive: true });\n  const artifacts = [];\n  for (const [goos, arch] of targets) {\n    for (const [name, packagePath] of RELEASE_BINARIES) {\n      const artifact = releaseArtifactName(name, goos, arch);\n      const output = join(out, artifact);\n      process.stderr.write(`build ${artifact}\\n`);\n      const result = spawnSync(\"go\", [\"build\", \"-trimpath\", \"-o\", output, packagePath], {\n        cwd: root,\n        env: { ...process.env, CGO_ENABLED: \"0\", GOOS: goos, GOARCH: arch },\n        stdio: \"inherit\",\n      });\n      if (result.error) throw result.error;","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/scripts/build-release-binaries.mjs#L34-L70","documentation":"Thrown by the release-binary build script's argument parser when it encounters a CLI argument that is not --out, --target, or --list. The parser is intentionally exhaustive with no pass-through, so any unrecognized flag aborts before a potentially long Go cross-compile starts.","triggerScenarios":"Running scripts/build-release-binaries.mjs with a flag like --jobs 4, --verbose, -t linux/amd64, or a positional argument; or passing a flag that belongs to a different script (e.g. --os instead of --target).","commonSituations":"Copy-pasting a command from docs of a different version of the script; muscle-memory flags from goreleaser or similar tools; a trailing typo or unquoted shell glob expanding into extra args.","solutions":["Remove the unrecognized flag — the script supports only --out <dir>, --target <goos/goarch> (repeatable), and --list.","Run the script with no arguments or --list to see the usage implied by the supported flags and defaults.","Check for shell expansion: quote arguments and ensure no stray tokens (e.g. an unquoted *) are appended."],"exampleFix":"# before\nnode scripts/build-release-binaries.mjs --verbose --target linux/amd64\n# after\nnode scripts/build-release-binaries.mjs --target linux/amd64","handlingStrategy":"validation","validationCode":"const ALLOWED = new Set([\"--out\", \"--target\", \"--list\"]);\nfor (const a of argv) {\n  const flag = a.startsWith(\"-\") ? a : null;\n  if (flag && !ALLOWED.has(flag) && !ALLOWED.has(flag.split(\"=\")[0])) {\n    throw new Error(`unsupported flag ${flag}; allowed: ${[...ALLOWED].join(\" \")}`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Wrap release invocations in a make/just recipe so humans never hand-type the flags.","Quote all arguments in CI scripts to prevent shell expansion adding tokens."],"tags":["cli","build","argument-validation"],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}