heygen-com/hyperframes · error · Error

Unknown flag: ${arg}

Error message

Unknown flag: ${arg}

What it means

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.

Source

Thrown at packages/aws-lambda/scripts/build-zip.ts:104

  for (const arg of argv.slice(2)) {
    if (arg.startsWith("--source=")) {
      const v = arg.slice("--source=".length);
      if (v !== "sparticuz" && v !== "chrome-headless-shell") {
        throw new Error(`--source must be 'sparticuz' or 'chrome-headless-shell' (got ${v})`);
      }
      opts.source = v;
    } else if (arg.startsWith("--max-unzipped=")) {
      opts.maxUnzippedBytes = Number.parseInt(arg.slice("--max-unzipped=".length), 10);
    } else if (arg.startsWith("--max-zipped=")) {
      opts.maxZippedBytes = Number.parseInt(arg.slice("--max-zipped=".length), 10);
    } else if (arg === "--help") {
      console.log(
        "Usage: tsx build-zip.ts [--source=sparticuz|chrome-headless-shell]\n" +
          "                       [--max-unzipped=<bytes>] [--max-zipped=<bytes>]",
      );
      process.exit(0);
    } else {
      throw new Error(`Unknown flag: ${arg}`);
    }
  }
  return opts;
}

async function main(): Promise<void> {
  const opts = parseArgs(process.argv);
  const start = Date.now();

  rmSync(distDir, { recursive: true, force: true });
  mkdirSync(distDir, { recursive: true });

  const stagingDir = join(distDir, "staging");
  mkdirSync(stagingDir, { recursive: true });

  console.log(`[build-zip] source=${opts.source}`);

  // 1. Bundle the handler.

View on GitHub (pinned to c2996c8626)

Solutions

  1. Use the equals-delimited form for all flags: --source=sparticuz, --max-zipped=N.
  2. Run 'tsx build-zip.ts --help' to see the complete flag set.
  3. Remove any unrecognized flags from your command.

Example fix

// before
tsx build-zip.ts --source sparticuz

// after
tsx build-zip.ts --source=sparticuz
Defensive patterns

Strategy: validation

Validate before calling

const KNOWN_FLAGS = ["--source=", "--max-unzipped=", "--max-zipped=", "--help"];
for (const arg of process.argv.slice(2)) {
  if (arg.startsWith("--") && !KNOWN_FLAGS.some((f) => arg.startsWith(f))) {
    console.error(`Unknown flag: ${arg}. Known: ${KNOWN_FLAGS.join(", ")}`);
    process.exit(1);
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of heygen-com/hyperframes@c2996c8626 (2026-08-12). Data as JSON: /api/errors/970fe8783ca01168. Report an issue: GitHub.