Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Slack integration is impossible to save #1253

Open
@kevinkjt2000

Description

@kevinkjt2000

Description of the problem, including code/CLI snippet

Same as #1188, slack integration is impossible to save. Even if pulling from an already configured integration!

import gitlab

gl = gitlab.Gitlab("https://secret-gitlab.com", private_token="s3cr3tTok3n")
project = gl.projects.get("org/project", lazy=True)
slack = project.services.get("slack")
# slack.webhook = "https://blah.com/asdf"  # raises AttributeError
slack.save() # an already configured integration raises the traceback below!

Expected Behavior

Obviously the webhook URL is not missing because the integration works when I trigger it by successfully sending a message to Slack. I would expect that an already configured slack integration would be saveable immediately after fetching it. Essentially this should be a no-op. Additionally, I had expected to be able to set the .webhook value without seeing an AttributeError. Then, I expected that the .properties dictionary would work since that is where the webhook shows up in an already configured integration.

Actual Behavior

Traceback (most recent call last):
  File "/py3.8/lib/python3.8/site-packages/gitlab/exceptions.py", line 279, in wrapped_f
    return f(*args, **kwargs)
  File "/py3.8/lib/python3.8/site-packages/gitlab/mixins.py", line 296, in update
    return http_method(path, post_data=new_data, files=files, **kwargs)
  File "/py3.8/lib/python3.8/site-packages/gitlab/__init__.py", line 713, in http_put
    result = self.http_request(
  File "/py3.8/lib/python3.8/site-packages/gitlab/__init__.py", line 565, in http_request
    raise GitlabHttpError(
gitlab.exceptions.GitlabHttpError: 400: webhook is missing

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/python/3.8.6/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/python/3.8.6/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/project/__main__.py", line 28, in <module>
    main()
  File "/project/__main__.py", line 23, in main
    slack.save()
  File "/py3.8/lib/python3.8/site-packages/gitlab/mixins.py", line 385, in save
    server_data = self.manager.update(obj_id, updated_data, **kwargs)
  File "/py3.8/lib/python3.8/site-packages/gitlab/v4/objects/__init__.py", line 4384, in update
    super(ProjectServiceManager, self).update(id, new_data, **kwargs)
  File "/py3.8/lib/python3.8/site-packages/gitlab/exceptions.py", line 281, in wrapped_f
    raise error(e.error_message, e.response_code, e.response_body) from e
gitlab.exceptions.GitlabUpdateError: 400: webhook is missing

Specifications

$ poetry export --without-hashes
certifi==2020.12.5; python_full_version >= "3.6.0"
chardet==3.0.4; python_full_version >= "3.6.0"
idna==2.10; python_full_version >= "3.6.0"
python-gitlab==2.5.0; python_full_version >= "3.6.0"
requests==2.25.0; python_full_version >= "3.6.0"
urllib3==1.26.2; python_full_version >= "3.6.0" and python_version < "4"
  • python-gitlab version: 2.5.0
  • API version you are using (v3/v4): whatever python-gitlab defaults to in the above code
  • Gitlab server version (or gitlab.com): 12.10.14-ee

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions