Skip to content
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

How to omit webhook secret update (config) when change webhook status active/inactive #2906

Open
AndriiY-SK opened this issue Feb 20, 2024 · 0 comments

Comments

@AndriiY-SK
Copy link

I want to deactivate/activate webhooks but PyGithub hook.edit require name and config field to update webhook.
I tried code below but this code delete a webhook secret

config = hook.config
del config['secret']
hook.edit(
  name=hook.name,
  config=config,
  active=False
)

Also, I tried to update config with orignal config and it broke secret value with *********

In the doc say that we should pass secret for webhook if secret previously had.
However, I tried code sample to patch webhook from the doc page to update just active field and it works

curl -L -X PATCH -H "Accept: application/vnd.github+json" -H "Authorization: Bearer <TOKEN>" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/<ORG>/<REPO>/hooks/<HOOK_ID> -d '{"active":true}'

image

Of course, you have implementation to omit webhooks secret in the Github UI repository settings but not in PyGithub

About PyGithub hook.edit implementation
Why do we need to check that name is str and config is dict but remove unsetted items like a name and config

        post_parameters = NotSet.remove_unset_items(
            {
                "name": name,
                "config": config,
                "events": events,
                "add_events": add_events,
                "remove_events": remove_events,
                "active": active,
            }
        )

Version: PyGithub==2.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant