Closed
Description
Creating a service lazily
The following code is meant to create a service object, even if the project in question does not yet have such an integration (i.e. a services.get
without lazy
would fail with a 404 error).
gl = gitlab.Gitlab(
gitlab_url,
private_token=gitlab_private_token
)
projects = gl.projects.list(search="devops4397", simple=True)
service = projects[0].services.get('jira', lazy=True)
Expected Behavior
service
should be a service object, and the following code should be executed.
Actual Behavior
The call fails with an exception:
Traceback (most recent call last):
File "/home/atlas/src/services/gitlab-group/server/scripts/.venv/lib64/python3.10/site-packages/gitlab/exceptions.py", line 307, in wrapped_f
return f(*args, **kwargs)
File "/home/atlas/src/services/gitlab-group/server/scripts/.venv/lib64/python3.10/site-packages/gitlab/mixins.py", line 111, in get
server_data = self.gitlab.http_get(path, **kwargs)
File "/home/atlas/src/services/gitlab-group/server/scripts/.venv/lib64/python3.10/site-packages/gitlab/client.py", line 761, in http_get
result = self.http_request(
File "/home/atlas/src/services/gitlab-group/server/scripts/.venv/lib64/python3.10/site-packages/gitlab/client.py", line 727, in http_request
raise gitlab.exceptions.GitlabHttpError(
gitlab.exceptions.GitlabHttpError: 404: 404 Integration Not Found
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/atlas/src/services/gitlab-group/server/scripts/testkod", line 19, in <module>
service = projects[0].services.get('jira', lazy=True)
File "/home/atlas/src/services/gitlab-group/server/scripts/.venv/lib64/python3.10/site-packages/gitlab/v4/objects/services.py", line 277, in get
obj = cast(ProjectService, super(ProjectServiceManager, self).get(id, **kwargs))
File "/home/atlas/src/services/gitlab-group/server/scripts/.venv/lib64/python3.10/site-packages/gitlab/exceptions.py", line 309, in wrapped_f
raise error(e.error_message, e.response_code, e.response_body) from e
gitlab.exceptions.GitlabGetError: 404: 404 Integration Not Found
Specifications
- python-gitlab version: 3.0.0 (it works fine with 2.10.1)
- API version you are using (v3/v4): gl.api_version says ”4”
- Gitlab server version (or gitlab.com): 14.6.2
- Python version: 3.10.1
Metadata
Metadata
Assignees
Labels
No labels