Skip to content

HTTP Error when downloading a release from python urllib

Summary

I am unable to use python urllib.request to download a public release from source. Note that other methods, such as wget, work without issue. Specifically, I'm trying to use Meson to download a wrap file so I can include a dependency for another project. Here is Meson's relevant code:

https://github.com/mesonbuild/meson/blob/c61f75adbfd5b2ce18de329e65217cc911f989d4/mesonbuild/wrap/wrap.py#L336

Steps to reproduce

Here is an example shell session using urllib by itself to open the request.

$ python3
Python 3.8.3 (default, May 14 2020, 11:03:12) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib.request
>>> urllib.request.urlopen('https://gitlab.com/nnooney-meson-wraps/abseil-cpp/-/archive/20200225.2/abseil-cpp-20200225.2.zip')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.8/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.8/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/usr/lib/python3.8/urllib/request.py", line 640, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.8/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden

Example Project

This is the releaase I am trying to obtain (downloading a zip archive of the source code): https://gitlab.com/nnooney-meson-wraps/abseil-cpp/-/releases/20200225.2

What is the current bug behavior?

I get an HTTP Error 403: Forbidden

What is the expected correct behavior?

I should get a successful HTTP response code.

Relevant logs and/or screenshots

See steps to reproduce

Output of checks

This bug happens on GitLab.com

Edited by Nicholas Nooney