{"record":{"id":"7e3cade15ced304a","repo":"heygen-com/hyperframes","slug":"source-must-be-sparticuz-or-chrome-headless-s","errorCode":null,"errorMessage":"--source must be 'sparticuz' or 'chrome-headless-shell' (got ${v})","messagePattern":"--source must be 'sparticuz' or 'chrome-headless-shell' \\(got (.+?)\\)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/aws-lambda/scripts/build-zip.ts","lineNumber":90,"sourceCode":"  // MiB) + bundled Node deps put us close to the ceiling. Chrome itself\n  // decompresses into Lambda's `/tmp` at cold start, which has its own\n  // 10 GiB budget, so the unzipped /var/task footprint above is what\n  // actually competes with Lambda's 250 MiB limit.\n  maxUnzippedBytes: 248 * 1024 * 1024,\n  // Lambda's only zipped-size cap is for direct console/CLI uploads (50\n  // MiB); S3-deployed functions are bounded by the unzipped ceiling. We\n  // gate at 150 MiB to flag a sudden bundle-size regression without\n  // false-failing on the natural ~100 MiB sparticuz + ffmpeg payload.\n  maxZippedBytes: 150 * 1024 * 1024,\n};\n\nfunction parseArgs(argv: string[]): BuildOptions {\n  const opts = { ...DEFAULT_OPTIONS };\n  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}","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/heygen-com/hyperframes/blob/c2996c8626135db5253519359d8a063d3bafad8d/packages/aws-lambda/scripts/build-zip.ts#L72-L108","documentation":"The --source flag selects which Chromium provider gets bundled into the Lambda ZIP. It accepts exactly two values: 'sparticuz' (the lightweight @sparticuz/chromium Lambda-optimized build) and 'chrome-headless-shell' (the heavier Puppeteer fallback). The parseArgs function rejects any other value at argument-parsing time, before any build work begins.","triggerScenarios":"Running build-zip.ts with --source set to anything other than 'sparticuz' or 'chrome-headless-shell' — e.g., --source=chrome, --source=chromium, --source=puppeteer, or a typo like --source=spartucus.","commonSituations":"Copy-pasting an outdated CI command; typos in GitHub Actions YAML; muscle memory from a different tool's flag names; trying a shorthand that was never supported.","solutions":["Use exactly --source=sparticuz or --source=chrome-headless-shell.","Run 'tsx build-zip.ts --help' to see the accepted values.","Omit the flag entirely to use the default source (sparticuz)."],"exampleFix":"// before\ntsx build-zip.ts --source=chrome\n\n// after\ntsx build-zip.ts --source=chrome-headless-shell","handlingStrategy":"validation","validationCode":"const VALID_SOURCES = [\"sparticuz\", \"chrome-headless-shell\"] as const;\nconst source = process.argv.find((a) => a.startsWith(\"--source=\"))?.slice(\"--source=\".length);\nif (source !== undefined && !VALID_SOURCES.includes(source as any)) {\n  console.error(`Invalid --source. Valid: ${VALID_SOURCES.join(\", \")}`);\n  process.exit(1);\n}","typeGuard":"function isValidSource(v: string): v is \"sparticuz\" | \"chrome-headless-shell\" {\n  return v === \"sparticuz\" || v === \"chrome-headless-shell\";\n}","tryCatchPattern":null,"preventionTips":["Validate --source in CI before invoking build-zip.ts.","Use a shared shell helper that constrains --source to the two accepted values.","Document the accepted values in the CI pipeline definition."],"tags":["cli","argument-validation","build","aws-lambda"],"backgroundTag":null,"analyzedSha":"c2996c8626135db5253519359d8a063d3bafad8d","analyzedAt":"2026-08-12T22:18:56.877Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}