Skip to content

Accessing gitLab from WSL from Windows 10 using a Python script returns "Project not found" but works on Windows and with curl on WSL

Summary

I have a script which fetches closed items from a gitlab project. Same script passes when running on Windows, fails when running on Windows Subsystem for Linux (WSL) and passes when executing with a curl in WSL. The reason script fails is because the GitLab API cannot return the projects when running in WSL.

Steps to reproduce

  • execute the script in windows <-- works
  • execute the script with curl on WSL <-- works
  • execute the script with python on WSL <-- problem

Example Project

This is the way I am fetching data from GitLab:

def get_items():

    url = "https://URL/api/v4/projects/server%2Fproducts%2FPROJECT/issues"

    payload = {}

    querystring = {"state": "closed", "per_page": "100"}

    headers = {
        'Content-Type': "application/json",
        'PRIVATE-TOKEN': os.environ.get("GITLAB_KEY") # enviromental variable added in windows 
    }

    requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

    response = requests.request(
        "GET", url, headers=headers, data=payload, params=querystring,  verify=False)

    print("RESPONSE " + response.text)
    return json.loads(response.text)

This is how I do the curl:

curl -X GET 'https://URL/api/v4/projects/server%2Fproducts%2FPROJECT/issues?per_page=100' -H 'Content-Type: application/json' -H 'PRIVATE-TOKEN: TOKEN' --insecure

What is the current bug behavior?

Script fails because GitLab can't return the projects

Output in WSL: RESPONSE {"message":"404 Project Not Found"}

Output in Windows + curl: RESPONSE [{"id":567,"iid":22, ...}, {"id":10,"iid":3, ...}]

What is the expected correct behavior?

Script should be executed successfully in all three ways and gitLab should not return "Project not found"

Results of GitLab environment info

Version: 11.9.8-ee Windows 10

Possible fixes

The problem I think is either on the way I make the GET API call request (eg maybe gitlab needs something more when accessing the API from unix environments) or there is a bug with the API.

/label ~bug

Edited by Marialena Shiamma