Skip to content

Skip hooks for repositories without admin access instead of logging a 404 error (#532) - #541

Merged
josegonzalez merged 1 commit into
josegonzalez:masterfrom
Iamrodos:fix/532-hooks-admin-skip
Nov 3, 2026
Merged

josegonzalez merged 1 commit into
josegonzalez:masterfrom
Iamrodos:fix/532-hooks-admin-skip

Conversation

@Iamrodos

@Iamrodos Iamrodos commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Fixes #532.

Reading /repos/{owner}/{repo}/hooks needs admin access, and GitHub returns 404 rather than 403 without it. An empty hooks list returns 200 []. #238 (for #176) assumed the 404 meant "no hooks" and turned the crash into a skip, but make_request_with_retry still logs API Error: 404 Not Found at ERROR first. That happens for every repository the token doesn't administer, such as starred repositories with --all-starred.

This PR makes the following changes:

  • When the repository listing reports permissions.admin: false, hooks are skipped without making the request. If the field is missing, the request goes ahead as before.
  • The 404 skip message now names the repository and the access it needs (admin, or Webhooks read for fine-grained tokens).
  • The README note "Starred public repo hooks blocking" no longer applied, since the backup carries on. It's replaced with a short note on the admin requirement.

Testing

  • tests/test_hooks.py covers:
    • non-admin: no request is made
    • admin, and the permissions field missing: the request is made
    • 404: skipped with the reason
    • other errors still propagate
  • pytest: 179 passed. flake8 with CI's flags and rst-lint README.rst pass.
  • Real runs, master vs this branch:
    • Public repos plus 23 starred repos with --all-starred --hooks: master logged 22 API Error: 404 lines and left 22 empty hooks/ folders. This branch made no hooks requests to the non-admin repos and logged no errors. The 5 hooks.json files for owned repos are byte-identical.
    • --all --private on one repo, and --private --issues --labels --milestones --releases --hooks across 25 repos: identical output and logs.

… 404 error (josegonzalez#532)

Reading hooks needs admin access, and GitHub returns 404 without it. When the
repository listing says the token isn't an admin, skip hooks without making the
request. The 404 skip message now names the repository and the permission it
needs, and the README note about hooks blocking starred backups is updated.
@josegonzalez
josegonzalez merged commit 098ba07 into josegonzalez:master Nov 3, 2026
10 checks passed
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

Successfully merging this pull request may close these issues.

Error message about missing hooks

2 participants