| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
I'm pretty sure this is a doc bug, https://docs.gitlab.com/ee/api/projects.html#get-single-project does also provide a get project by id endpoint only.
Yeah, I had suspected this might be the case, as I am relatively familiar with the API and know you can't get the project by anything but the ID.
I can work around this by using projects.list(search='myname') and then checking each match to see if the namespace and project name both match. So, at the end of the day it's not a blocker for me.
If the solution is a doc fix, I can submit a pull request. However, if it is deemed useful to add this functionality, I would need to roll up my sleeves and get more familiar with the codebase.
Whould be awesome to get a contribution within the docs on this from your side.
Cool, just opened #914
If you read correctly on the doc link @bufferoverflow provided, it says The ID or URL-encoded path of the project.
The project's doc was correctly but the feature is not working, and I'm not sure why. It appears to me that it's querying the correct endpoint.
I'd preffer to reopen this issue rather than opening a new one :)
The reply of both the id and the project path are the same.
https://salsa.debian.org/api/v4/projects/27916
https://salsa.debian.org/api/v4/projects/salsa-ci-team%2Fpipeline
It happen to work on gitlab.com, but not on the instance I previously shared.
In [1]: import gitlab
In [2]: gl = gitlab.Gitlab('https://gitlab.com')
In [3]: gl.projects.get('inakimalerba/test-project')
Out[3]: <Project id:13176136>I'm trying to debug the reason behind the failure.
It's possible that the instance admins might have blocked some kind of requests, but the endpoint works good with any other requests.
In [5]: import requests
In [6]: session = requests.Session()
...: session.headers.update({'User-Agent': 'Mozilla/5.0'})
...:
In [7]: gl = gitlab.Gitlab('https://salsa.debian.org/', session=session)
In [8]: gl.projects.get("salsa-ci-team/pipeline")
[...]
/home/ina/.local/lib/python3.7/site-packages/gitlab/exceptions.py in wrapped_f(*args, **kwargs)
259 return f(*args, **kwargs)
260 except GitlabHttpError as e:
--> 261 raise error(e.error_message, e.response_code, e.response_body)
262
263 return wrapped_f
GitlabGetError: 404: 404 Project Not Found$ curl https://salsa.debian.org/api/v4/projects/salsa-ci-team%2Fpipeline
{"id":27916,"description":"♻️ Gitlab CI pipeline definition to build and test Debian projects.","name":"pipeline","name_with_namespace":"Salsa CI Team / pipeline","path":"pipeline","path_with_namespace":"salsa-ci-team/pipeline","created_at":"2018-06-11T16:18:20.834Z","default_branch":"master","tag_list":["autopkgtest","blhc","build","ci","debian","gbp","lintian","package","pipeline","piuparts","reprotest","salsa","test"],"ssh_url_to_repo":"git@salsa.debian.org:salsa-ci-team/pipeline.git","http_url_to_repo":"https://salsa.debian.org/salsa-ci-team/pipeline.git","web_url":"https://salsa.debian.org/salsa-ci-team/pipeline","readme_url":"https://salsa.debian.org/salsa-ci-team/pipeline/blob/master/README.md","avatar_url":null,"star_count":23,"forks_count":32,"last_activity_at":"2019-10-31T19:35:43.180Z","namespace":{"id":3783,"name":"Salsa CI Team","path":"salsa-ci-team","kind":"group","full_path":"salsa-ci-team","parent_id":null,"avatar_url":null,"web_url":"https://salsa.debian.org/groups/salsa-ci-team"}}Edit: Oops I wrote a lengthy comment but actually it's a simple issue with your trailing slash. I added some debug prints in _build_url() and get this:
>>> import gitlab
>>>
>>> gl = gitlab.Gitlab('https://gitlab.com/')
>>> gl.projects.get('inakimalerba/test-project')
Constructed URL:
https://gitlab.com//api/v4/projects/inakimalerba%2Ftest-project
<Project id:13176136>
>>>
>>> gl = gitlab.Gitlab('https://salsa.debian.org/')
>>> gl.projects.get("salsa-ci-team/pipeline")
Constructed URL:
https://salsa.debian.org//api/v4/projects/salsa-ci-team%2Fpipeline
Traceback (most recent call last):
So the proxy on gitlab.com handles the double slash but not Apache on salsa.debian.org. For now, removing the trailing slash will work, and for python-gitlab just stripping the trailing slash for the gitlab URL would probably be enough :)
| Back | FazBrowse Home | New Git URL |
Description of the problem, including code/CLI snippet
Attempt to make a query using the project's path, per the example in the documentation.
Expected Behavior
python-gitlab resolves the group and project name, returning a Project object for that project.
Actual Behavior
Exception is raised with the following error:
From the URL in the error, it appears that the project is not being resolved at all and that python-gitlab is assuming the value passed in was the project ID.
Specifications