{"record":{"id":"970fe8783ca01168","repo":"heygen-com/hyperframes","slug":"unknown-flag-arg","errorCode":null,"errorMessage":"Unknown flag: ${arg}","messagePattern":"Unknown flag: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/aws-lambda/scripts/build-zip.ts","lineNumber":104,"sourceCode":"  for (const arg of argv.slice(2)) {\n    if (arg.startsWith(\"--source=\")) {\n      const v = arg.slice(\"--source=\".length);\n      if (v !== \"sparticuz\" && v !== \"chrome-headless-shell\") {\n        throw new Error(`--source must be 'sparticuz' or 'chrome-headless-shell' (got ${v})`);\n      }\n      opts.source = v;\n    } else if (arg.startsWith(\"--max-unzipped=\")) {\n      opts.maxUnzippedBytes = Number.parseInt(arg.slice(\"--max-unzipped=\".length), 10);\n    } else if (arg.startsWith(\"--max-zipped=\")) {\n      opts.maxZippedBytes = Number.parseInt(arg.slice(\"--max-zipped=\".length), 10);\n    } else if (arg === \"--help\") {\n      console.log(\n        \"Usage: tsx build-zip.ts [--source=sparticuz|chrome-headless-shell]\\n\" +\n          \"                       [--max-unzipped=<bytes>] [--max-zipped=<bytes>]\",\n      );\n      process.exit(0);\n    } else {\n      throw new Error(`Unknown flag: ${arg}`);\n    }\n  }\n  return opts;\n}\n\nasync function main(): Promise<void> {\n  const opts = parseArgs(process.argv);\n  const start = Date.now();\n\n  rmSync(distDir, { recursive: true, force: true });\n  mkdirSync(distDir, { recursive: true });\n\n  const stagingDir = join(distDir, \"staging\");\n  mkdirSync(stagingDir, { recursive: true });\n\n  console.log(`[build-zip] source=${opts.source}`);\n\n  // 1. Bundle the handler.","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/heygen-com/hyperframes/blob/c2996c8626135db5253519359d8a063d3bafad8d/packages/aws-lambda/scripts/build-zip.ts#L86-L122","documentation":"The build-zip CLI parser only recognizes --source=, --max-unzipped=, --max-zipped=, and --help. Any other token starting with -- falls through all the if/else branches and hits the final else clause which throws. Notably the parser only accepts the equals-delimited form, not space-separated pairs.","triggerScenarios":"Passing a flag not in the recognized set, or using the space-separated form (e.g., --source sparticuz) which the parser treats as --source=<nothing> followed by an unknown bare token 'sparticuz'. Also triggered by leftover flags from a previous script version or flags from a different tool.","commonSituations":"Using space-separated syntax (--source sparticuz) when only equals form works; passing --verbose, --output, or other unsupported flags; copy-pasting a command from docs for a different script.","solutions":["Use the equals-delimited form for all flags: --source=sparticuz, --max-zipped=N.","Run 'tsx build-zip.ts --help' to see the complete flag set.","Remove any unrecognized flags from your command."],"exampleFix":"// before\ntsx build-zip.ts --source sparticuz\n\n// after\ntsx build-zip.ts --source=sparticuz","handlingStrategy":"validation","validationCode":"const KNOWN_FLAGS = [\"--source=\", \"--max-unzipped=\", \"--max-zipped=\", \"--help\"];\nfor (const arg of process.argv.slice(2)) {\n  if (arg.startsWith(\"--\") && !KNOWN_FLAGS.some((f) => arg.startsWith(f))) {\n    console.error(`Unknown flag: ${arg}. Known: ${KNOWN_FLAGS.join(\", \")}`);\n    process.exit(1);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always use the equals-delimited form for build-zip flags.","Run 'tsx build-zip.ts --help' to review the accepted flag set before adding new ones.","Lint CI commands against the known flag list."],"tags":["cli","argument-validation","build"],"backgroundTag":null,"analyzedSha":"c2996c8626135db5253519359d8a063d3bafad8d","analyzedAt":"2026-08-12T22:18:56.877Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}