bazel: http_archive gets 406 error, can download using browser

Description of the problem:

When trying to download an archive using http_archive from a project on gitlab, I get a 406 error. However, I can download the archive using my browser.

Bugs: what’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

I was able to reproduce with the code posted here.

cd /tmp
git clone https://github.com/fenollp/gitlab_bazel_406_on_download_and_extract.git
cd gitlab_bazel_406_on_download_and_extract 
bazel sync
INFO: Repository radamsa instantiated at:
  no stack (--record_rule_instantiation_callstack not enabled)
Repository rule http_archive defined at:
  /home/doug/.cache/bazel/_bazel_doug/220a71cbe7341f96c28e272f1720771c/external/bazel_tools/tools/build_defs/repo/http.bzl:336:16: in <toplevel>
WARNING: Download from https://gitlab.com/akihe/radamsa/-/archive/v0.6/radamsa-v0.6.tar.bz2 failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException GET returned 406 Not Acceptable
ERROR: An error occurred during the fetch of repository 'radamsa':
   java.io.IOException: Error downloading [https://gitlab.com/akihe/radamsa/-/archive/v0.6/radamsa-v0.6.tar.bz2] to /home/doug/.cache/bazel/_bazel_doug/220a71cbe7341f96c28e272f1720771c/external/radamsa/radamsa-v0.6.tar.bz2: GET returned 406 Not Acceptable
ERROR: java.io.IOException: Error downloading [https://gitlab.com/akihe/radamsa/-/archive/v0.6/radamsa-v0.6.tar.bz2] to /home/doug/.cache/bazel/_bazel_doug/220a71cbe7341f96c28e272f1720771c/external/radamsa/radamsa-v0.6.tar.bz2: GET returned 406 Not Acceptable
Loading: loading...

What operating system are you running Bazel on?

Ubuntu 19.10

What’s the output of bazel info release?

INFO: Invocation ID: 389ae0d8-4b39-4f14-8503-6725a9892926
release 3.1.0

What’s the output of git remote get-url origin ; git rev-parse master ; git rev-parse HEAD ?

https://github.com/fenollp/gitlab_bazel_406_on_download_and_extract.git
e31a3678cff03c3739722de0b143ff87996c55f5
e31a3678cff03c3739722de0b143ff87996c55f5

Have you found anything relevant by searching the web?

Other people have also encountered this issue:

Stack overflow bazel-discuss

However, none of the suggestions are fixes, just workarounds. This looks like a bug to me because I can download the archive fine with my browser.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 11
  • Comments: 19 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Strangely, downloading manually and then rerunning the bazel command seems to make it start working for me. (I’m running into this with Eigen.)