Repository navigation
Allow updating hooks without resending configuration - #3630
Conversation
EnricoMi
left a comment
There was a problem hiding this comment.
Thanks for fixing this! Looks like the hook name argument has been removed. The name argument should be deprecated. There might be old Github Enterprise versions out there still supporting it.
| @@ -169,10 +169,10 @@ | |||
| """ | |||
| :calls: `PATCH /repos/{owner}/{repo}/hooks/{hook_id} <https://docs.github.com/en/rest/reference/repos#webhooks>`_ | |||
There was a problem hiding this comment.
| :calls: `PATCH /repos/{owner}/{repo}/hooks/{hook_id} <https://docs.github.com/en/rest/reference/repos#webhooks>`_ | |
| :calls: `PATCH /repos/{owner}/{repo}/hooks/{hook_id} <https://docs.github.com/en/rest/repos/webhooks#update-a-repository-webhook>`_ |
| assert is_optional_list(add_events, str), add_events | ||
| assert is_optional_list(remove_events, str), remove_events | ||
| assert is_optional(active, bool), active | ||
| post_parameters = NotSet.remove_unset_items( |
There was a problem hiding this comment.
Deprecate name
| if is_defined(name): | |
| warnings.warn( | |
| "Arguments name is deprecated, the name of a hook cannot be changed", | |
| category=DeprecationWarning, | |
| ) | |
| post_parameters = NotSet.remove_unset_items( |
You may need to catch the deprecation warning in tests for them not to fail:
with self.assertWarns(DeprecationWarning) as warning:
hook.edit("name")
self.assertWarning(
warning,
"Arguments name is deprecated, the name of a hook cannot be changed",
)
There was a problem hiding this comment.
Is the name argument ignored (name does not change) or do we get an error when attempting to change / provide the name? Maybe we should use this warning instead
"Arguments name is deprecated, the name of a hook cannot be changed and is ignored"
There was a problem hiding this comment.
Kept name in the request for older Enterprise versions and added DeprecationWarning. The current update documentation no longer lists it, but I haven't verified whether a live server ignores or rejects it. I used Argument name is deprecated without claiming either behavior. The tests check the warning and preserve the legacy payload.
Also updated the endpoint link and removed request capture from the two new tests; their replay files contain the expected requests.
| self.assertEqual(len(requests), 1) | ||
| self.assertEqual(requests[0].verb, "PATCH") | ||
| self.assertEqual(requests[0].url, "/orgs/example/hooks/42") | ||
| self.assertEqual(json.loads(requests[0].input), {"active": False}) |
There was a problem hiding this comment.
No need to capture the requests, we usually inspect the replay data file. That should be sufficient here. Same for testEditActiveOnly.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3630 +/- ##
==========================================
+ Coverage 97.00% 97.11% +0.11%
==========================================
Files 172 182 +10
Lines 18934 20628 +1694
==========================================
+ Hits 18366 20032 +1666
- Misses 568 596 +28 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Test Results 10 files ± 0 10 suites ±0 9m 22s ⏱️ + 1m 0s Results for commit bb1fda4. ± Comparison against base commit afdd9d8. This pull request removes 1 and adds 24 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
|
Small thing, the org webhook update docs still list name as a body param, so the new deprecation warning also fires for org hooks where it's valid. Maybe only warn for repo hooks, or say in the message it only applies there? |
|
Checked it, org hooks don't warn anymore and repo hooks still do. @EnricoMi looks good to me, thx. |
1c5c9be to
cc65df2
Compare
|
I have restructured tests and recorded test data. Also rephrased the is-repo-hook check. |
Replay data recently added to main does not match the requests the
code sends, which request header and body matching now detect:
- Issue134.testGetOAuthScopes{FetchedOnAccess,UnknownWithoutScopeHeader}
mask the token as '***' instead of 'token private_token_removed'.
- Hook.testCreate records an Accept header that create_hook does not
send.
- Hook.testEditWithMinimalParametersRepositoryHook records the name
argument, which edit(config=...) no longer sends since name became
optional (#3630).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [PyGithub](https://redirect.github.com/pygithub/pygithub) | `==2.10.0` → `==2.11.0` |  |  | --- ### Release Notes <details> <summary>pygithub/pygithub (PyGithub)</summary> ### [`v2.11.0`](https://redirect.github.com/PyGithub/PyGithub/releases/tag/v2.11.0) [Compare Source](https://redirect.github.com/pygithub/pygithub/compare/v2.10.0...v2.11.0) #### What's Changed ##### New Features - Add deployment branch policies to `Environment` by [@​cvas22](https://redirect.github.com/cvas22) in [PyGithub/PyGithub#3612](https://redirect.github.com/PyGithub/PyGithub/pull/3612) - Add support for branch rulesets by [@​EnricoMi](https://redirect.github.com/EnricoMi) in [PyGithub/PyGithub#3617](https://redirect.github.com/PyGithub/PyGithub/pull/3617) - Allow iterating `PaginatedList` by pages by [@​EnricoMi](https://redirect.github.com/EnricoMi) in [PyGithub/PyGithub#3603](https://redirect.github.com/PyGithub/PyGithub/pull/3603) - Add `Organization.get_failed_invitations` by [@​cvas22](https://redirect.github.com/cvas22) in [PyGithub/PyGithub#3608](https://redirect.github.com/PyGithub/PyGithub/pull/3608) - Add `Issue.transfer` to move an issue to another repository by [@​cvas22](https://redirect.github.com/cvas22) in [PyGithub/PyGithub#3631](https://redirect.github.com/PyGithub/PyGithub/pull/3631) - Add `Repository.get_actions_permissions` and `ActionsRepositoryPermissions.edit` by [@​andrewfish0](https://redirect.github.com/andrewfish0) in [PyGithub/PyGithub#3583](https://redirect.github.com/PyGithub/PyGithub/pull/3583) ##### Improvements - Apply schema to `SecretScanAlert` by [@​EnricoMi](https://redirect.github.com/EnricoMi) in [PyGithub/PyGithub#3573](https://redirect.github.com/PyGithub/PyGithub/pull/3573) - Respect application logging configuration by default by [@​vzer200](https://redirect.github.com/vzer200) in [PyGithub/PyGithub#3572](https://redirect.github.com/PyGithub/PyGithub/pull/3572) - Update classes using OpenAPI spec by [@​EnricoMi](https://redirect.github.com/EnricoMi) in [PyGithub/PyGithub#3606](https://redirect.github.com/PyGithub/PyGithub/pull/3606) - Rework rate limit support by [@​EnricoMi](https://redirect.github.com/EnricoMi) in [PyGithub/PyGithub#3602](https://redirect.github.com/PyGithub/PyGithub/pull/3602) - Add rate limit information to `PaginatedList` pages by [@​EnricoMi](https://redirect.github.com/EnricoMi) in [PyGithub/PyGithub#3605](https://redirect.github.com/PyGithub/PyGithub/pull/3605) - Derive `Commit.repository` from the commit url by [@​b84330808](https://redirect.github.com/b84330808) in [PyGithub/PyGithub#3599](https://redirect.github.com/PyGithub/PyGithub/pull/3599) - Updating pyproject.toml by [@​EnricoMi](https://redirect.github.com/EnricoMi) in [PyGithub/PyGithub#3623](https://redirect.github.com/PyGithub/PyGithub/pull/3623) - Fix `creator` type hint in `Repository.get_issues` ([#​3084](https://redirect.github.com/pygithub/pygithub/issues/3084)) by [@​zxc1031408077](https://redirect.github.com/zxc1031408077) in [PyGithub/PyGithub#3598](https://redirect.github.com/PyGithub/PyGithub/pull/3598) - Fetch `Github.oauth_scopes` on access when the scopes are not known yet by [@​StrikeRougeAgent](https://redirect.github.com/StrikeRougeAgent) in [PyGithub/PyGithub#3633](https://redirect.github.com/PyGithub/PyGithub/pull/3633) - Reject a zero step slice in `PaginatedList` by [@​yuefdev](https://redirect.github.com/yuefdev) in [PyGithub/PyGithub#3597](https://redirect.github.com/PyGithub/PyGithub/pull/3597) ##### Bug Fixes - Remove commit ref support from `Workflow.create_dispatch` by [@​laysauchoa](https://redirect.github.com/laysauchoa) in [PyGithub/PyGithub#2931](https://redirect.github.com/PyGithub/PyGithub/pull/2931) - Fix listing installation repositories with user authentication by [@​hansu650](https://redirect.github.com/hansu650) in [PyGithub/PyGithub#3571](https://redirect.github.com/PyGithub/PyGithub/pull/3571) - Fix `openapi.py` and `sort_class.py` for `_useAttributes` with custom if statements by [@​EnricoMi](https://redirect.github.com/EnricoMi) in [PyGithub/PyGithub#3619](https://redirect.github.com/PyGithub/PyGithub/pull/3619) - Keep query string when following 301 redirects by [@​Enesuygurs](https://redirect.github.com/Enesuygurs) in [PyGithub/PyGithub#3600](https://redirect.github.com/PyGithub/PyGithub/pull/3600) - Allow Enterprise release asset download redirects to `/storage/releases/` by [@​wozhenbang2004](https://redirect.github.com/wozhenbang2004) in [PyGithub/PyGithub#3629](https://redirect.github.com/PyGithub/PyGithub/pull/3629) - Allow updating hooks without resending configuration by [@​wozhenbang2004](https://redirect.github.com/wozhenbang2004) in [PyGithub/PyGithub#3630](https://redirect.github.com/PyGithub/PyGithub/pull/3630) - Fix `PaginatedList.total_count` for custom `toal_count_item` by [@​EnricoMi](https://redirect.github.com/EnricoMi) in [PyGithub/PyGithub#3648](https://redirect.github.com/PyGithub/PyGithub/pull/3648) ##### Maintenance - Generate a GraphQL API reference from method annotations by [@​lzyrtxtp](https://redirect.github.com/lzyrtxtp) in [PyGithub/PyGithub#3585](https://redirect.github.com/PyGithub/PyGithub/pull/3585) - Replace `black`, `pyupgrade`, and `docformatter` with `ruff` by [@​EnricoMi](https://redirect.github.com/EnricoMi) in [PyGithub/PyGithub#3592](https://redirect.github.com/PyGithub/PyGithub/pull/3592) - Add ruff reformat commit to .git-blame-ignore-revs by [@​EnricoMi](https://redirect.github.com/EnricoMi) in [PyGithub/PyGithub#3593](https://redirect.github.com/PyGithub/PyGithub/pull/3593) - Fix logging tests by [@​EnricoMi](https://redirect.github.com/EnricoMi) in [PyGithub/PyGithub#3594](https://redirect.github.com/PyGithub/PyGithub/pull/3594) - Replace responses with vcrpy by [@​EnricoMi](https://redirect.github.com/EnricoMi) in [PyGithub/PyGithub#3563](https://redirect.github.com/PyGithub/PyGithub/pull/3563) - Restrict workflow permissions by [@​EnricoMi](https://redirect.github.com/EnricoMi) in [PyGithub/PyGithub#3611](https://redirect.github.com/PyGithub/PyGithub/pull/3611) - Fix syntax error in code scanning alert example by [@​puhupwasbind301](https://redirect.github.com/puhupwasbind301) in [PyGithub/PyGithub#3607](https://redirect.github.com/PyGithub/PyGithub/pull/3607) - Clarify that Repository.get_commit accepts any ref by [@​cvas22](https://redirect.github.com/cvas22) in [PyGithub/PyGithub#3609](https://redirect.github.com/PyGithub/PyGithub/pull/3609) - Document refreshing cached objects with update by [@​yuefdev](https://redirect.github.com/yuefdev) in [PyGithub/PyGithub#3596](https://redirect.github.com/PyGithub/PyGithub/pull/3596) - Pin tox below 4.67.14 in CI by [@​EnricoMi](https://redirect.github.com/EnricoMi) in [PyGithub/PyGithub#3620](https://redirect.github.com/PyGithub/PyGithub/pull/3620) - Test built whl package in CI by [@​EnricoMi](https://redirect.github.com/EnricoMi) in [PyGithub/PyGithub#3624](https://redirect.github.com/PyGithub/PyGithub/pull/3624) - Document GitHub App client IDs for AppAuth by [@​akoroderdeniteenfeld-sudo](https://redirect.github.com/akoroderdeniteenfeld-sudo) in [PyGithub/PyGithub#3637](https://redirect.github.com/PyGithub/PyGithub/pull/3637) - Show how to read an annotated tag message by [@​akoroderdeniteenfeld-sudo](https://redirect.github.com/akoroderdeniteenfeld-sudo) in [PyGithub/PyGithub#3643](https://redirect.github.com/PyGithub/PyGithub/pull/3643) - Clarify which object cancels an organization invitation by [@​akoroderdeniteenfeld-sudo](https://redirect.github.com/akoroderdeniteenfeld-sudo) in [PyGithub/PyGithub#3645](https://redirect.github.com/PyGithub/PyGithub/pull/3645) - Obfuscate OpenAPI test diff line context by [@​EnricoMi](https://redirect.github.com/EnricoMi) in [PyGithub/PyGithub#3647](https://redirect.github.com/PyGithub/PyGithub/pull/3647) - Add OpenAPI script tests around anyof by [@​EnricoMi](https://redirect.github.com/EnricoMi) in [PyGithub/PyGithub#3613](https://redirect.github.com/PyGithub/PyGithub/pull/3613) - Fixing rst and md formatting issues by [@​EnricoMi](https://redirect.github.com/EnricoMi) in [PyGithub/PyGithub#3622](https://redirect.github.com/PyGithub/PyGithub/pull/3622) - Fix VCR replay matching by [@​EnricoMi](https://redirect.github.com/EnricoMi) in [PyGithub/PyGithub#3646](https://redirect.github.com/PyGithub/PyGithub/pull/3646) - Add `noRecord()` to reuse replay data when recording by [@​cvas22](https://redirect.github.com/cvas22) in [PyGithub/PyGithub#3618](https://redirect.github.com/PyGithub/PyGithub/pull/3618) **Full Changelog**: <PyGithub/PyGithub@v2.10.0...v2.11.0> </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/lettuce-financial/github-bot-signed-commit). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NS4xMi4wIiwidXBkYXRlZEluVmVyIjoiNDUuMTIuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->
Hook.edit(active=False)currently raisesTypeErrorunless callers supplynameandconfig. Make both optional withNotSet, so changing webhook status does not require resending its configuration. Existing positional calls still work.nameis deprecated for repository webhooks and is still included in requests for compatibility. Organization webhooks continue to acceptname.Add replay coverage for repository and organization hooks and keep
Noneinvalid. The previous revision passed 266 Hook, Repository and Organization tests, as well as mypy and pre-commit. A loopback HTTP check confirms that active-only updates send only{"active": false}and that legacy repository calls retain their payload and emit the warning. The new regression verifies that organization updates send an explicitnamewithout a deprecation warning. The replay responses are synthetic. Live webhook secrets were not tested.Fixes #2906.