bazelbuild/bazel · error · Exception

unknown archive type "%s"

Error message

unknown archive type "%s"

What it means

Raised by Bazel's combine_distfiles.py packaging helper, which merges distribution archives into a single zip. It only knows how to copy entries from '.tar' inputs (copy_tar_to_zip) and '.zip' inputs (copy_zip_to_zip); any other file extension aborts with 'unknown archive type'.

Source

Thrown at combine_distfiles.py:46

def main():
  output_zip = os.path.join(os.getcwd(), sys.argv[1])
  input_files = sorted(sys.argv[2:])

  # Copy all the input_files into output_zip.
  # Adding contextlib.closing to be python 2.6 (for centos 6.7) compatible
  with contextlib.closing(
      zipfile.ZipFile(output_zip, "w", zipfile.ZIP_DEFLATED)) as output_zip:

    def _normalize(path):
      return path[2:] if path.startswith("./") else path

    for input_file in input_files:
      if input_file.endswith(".tar"):
        copy_tar_to_zip(output_zip, input_file, _normalize)
      elif input_file.endswith(".zip"):
        copy_zip_to_zip(output_zip, input_file, _normalize)
      else:
        raise Exception("unknown archive type \"%s\"" % input_file)


if __name__ == "__main__":
  main()

View on GitHub (pinned to e6e199d060)

Solutions

  1. Repackage the offending input as a plain .tar or .zip (gunzip the .tar.gz, rezip the .jar contents) and update the input list.
  2. Check the exact filename printed in the message for extension typos or uppercase variants.
  3. If a new format is genuinely required, extend the script with a handler branch instead of bypassing the check.

Example fix

# before
input_files = ["bazel-dist.tar.gz", "extra.zip"]

# after
input_files = ["bazel-dist.tar", "extra.zip"]  # decompress to plain .tar first
Defensive patterns

Strategy: validation

Validate before calling

import os

valid_exts = ('.tar', '.zip')
bad = [f for f in input_files if not f.endswith(valid_exts)]
if bad:
    raise ValueError('unsupported inputs (need .tar/.zip): %s' % bad)

Prevention

When it happens

Trigger: Running the combine_distfiles tool with an input_files list containing a file whose name does not end in '.tar' or '.zip' (e.g. '.tar.gz', '.tgz', '.jar' or a raw file).

Common situations: A dependency's distfile was re-compressed as .tar.gz or renamed; a new input added to the genrule invoking this script uses an unsupported format; case-sensitive extension mismatch ('.ZIP').

Related errors


AI-assisted analysis of bazelbuild/bazel@e6e199d060 (2026-08-14). Data as JSON: /api/errors/a475b6d0ed7210bb. Report an issue: GitHub.