mozilla/pdf.js · error · Error

Missing "--hash <commit-hash>" argument.

Error message

Missing "--hash <commit-hash>" argument.

What it means

The `release-brotli` gulp task downloads the Brotli decoder (`decode.js`) pinned to a specific google/brotli commit. It requires `--hash <commit-hash>` on the command line; the code scans process.argv for `--hash` and checks that a value follows it. If the flag is absent or is the last token (no value), the task aborts before touching the network. This prevents downloading an arbitrary/latest commit and forces a deliberate, reproducible pin.

Source

Thrown at gulpfile.mjs:1120

  done();
});

gulp.task("default", function (done) {
  console.log("Available tasks:");
  const tasks = Object.keys(gulp.registry().tasks());
  for (const taskName of tasks.sort()) {
    if (taskName.endsWith("-pre")) {
      continue;
    }
    console.log("  " + taskName);
  }
  done();
});

gulp.task("release-brotli", async function (done) {
  const hashIndex = process.argv.indexOf("--hash");
  if (hashIndex === -1 || hashIndex + 1 >= process.argv.length) {
    throw new Error('Missing "--hash <commit-hash>" argument.');
  }
  console.log();
  console.log("### Getting Brotli js file for release");

  const OUTPUT_DIR = "./external/brotli/";
  const hash = process.argv[hashIndex + 1];
  const url = `https://raw.githubusercontent.com/google/brotli/${hash}/js/decode.js`;
  const outputPath = OUTPUT_DIR + "decode.js";
  const res = await fetch(url);
  const fileStream = fs.createWriteStream(outputPath, { flags: "w" });
  await finished(stream.Readable.fromWeb(res.body).pipe(fileStream));
  fileStream.end();

  console.log(`Brotli js file saved to: ${outputPath}`);

  done();
});

View on GitHub (pinned to 5903d58d58)

Solutions

  1. Pass a full commit hash: `gulp release-brotli --hash <40-char-sha>` (use the google/brotli commit you want to vendor).
  2. Verify the hash exists in google/brotli before running (avoids a later 404 on the fetch).
  3. Update your release runbook so the `--hash` value is mandatory and templated.

Example fix

# before
gulp release-brotli
# after
gulp release-brotli --hash c85afa57ab24b1f4d1a4c48e63d44a3d49f4caa2
Defensive patterns

Strategy: validation

Validate before calling

function assertHashArg(argv) {
  const i = argv.indexOf('--hash');
  const v = i !== -1 ? argv[i + 1] : undefined;
  if (!v || !/^[0-9a-f]{7,40}$/i.test(v)) {
    throw new Error('release-brotli requires --hash <commit-hash> (7-40 hex chars)');
  }
  return v;
}

Prevention

When it happens

Trigger: Running `gulp release-brotli` with no `--hash`; passing `--hash` as the final argument with no commit hash after it; a typo'd flag name (e.g. `--commit`).

Common situations: Cutting a release and forgetting the hash; copy-pasting an old release command whose hash field was never filled in; CI release job template missing the substitution.

Related errors


AI-assisted analysis of mozilla/pdf.js@5903d58d58 (2026-08-13). Data as JSON: /api/errors/bbe1d7001dcb5bbc. Report an issue: GitHub.