Skip to content

Lazy creation of service object still fails with 404 error #1828

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
goeranu opened this issue Jan 13, 2022 · 1 comment · Fixed by #1829
Closed

Lazy creation of service object still fails with 404 error #1828

goeranu opened this issue Jan 13, 2022 · 1 comment · Fixed by #1829

Comments

@goeranu
Copy link

goeranu commented Jan 13, 2022

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
JohnVillalovos added a commit that referenced this issue Jan 13, 2022
Commit 8da0b75 added the `lazy`
parameter to the services `get()` method but missed then using the
`lazy` parameter when it called `super(...).get(...)`

Closes: #1828
JohnVillalovos added a commit that referenced this issue Jan 13, 2022
Commit 8da0b75 added the `lazy`
parameter to the services `get()` method but missed then using the
`lazy` parameter when it called `super(...).get(...)`

Closes: #1828
@JohnVillalovos
Copy link
Member

Thanks for reporting this issue. I have proposed a fix in PR #1829.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants