fix(github-app): stop warning about undeliverable webhook events
Problem
The startup subscription check warns on every boot even for a correctly configured App, because required_trigger_events() listed three events GET /app can never report.
pull_request_targetis not a webhook event at all. It is a workflow trigger preloop synthesizes from thepull_requestwebhook (events/pull_request.rs), so GitHub has nothing to report and the entry could never be satisfied.check_run/check_suiteare auto-subscribed for Apps holdingchecks: writeand are omitted fromevents, so their absence never meant they were undelivered. Verified against a live App: 17check_suitedeliveries whileeventswas["pull_request","push"].
It also told operators to "tick the missing events" for events whose checkbox GitHub does not render, because the App lacks the gating permission — a dead end that cost real debugging time.
Change
- Drop
pull_request_target; treatcheck_run/check_suiteas satisfied bychecks: write. read_app_events_atbecomesread_app_subscription_at, returning events and permissions (AppSubscription) from the response it already fetched.- The warning now splits its advice: events tickable today, versus events needing a permission grant (and installation acceptance) first.
- The per-event permission mapping mirrors each event's "must have at least read-level access for the …" clause in GitHub's webhook events reference.
- Docs updated (
docs/github-app-webhook.md,docs/github-app-api-compat.md), which published the same wrong list.
Tests
The old test built its "complete subscription" from the table under test, so it passed no matter how many fictional event names the list contained. It now asserts every entry against a literal list of real GitHub webhook events, plus new coverage for the implicitly-delivered check events and for permission bucketing.
Against the real App shape (events: [pull_request, push], permissions: {checks: write, contents: read, metadata: read, pull_requests: read}) the warning drops from 12 entries to 9 real ones, split into 6 tickable now and 3 blocked on the Issues/Actions permissions.
just test-ci passes locally (fmt, clippy, tests, conformance).
Drive-by
store.rs carried a clippy::manual_is_multiple_of error that already failed just test-ci on main under Rust 1.97. Unrelated to this fix, but the gate cannot run without it.
Summary by cubic
Fixes the GitHub App startup subscription check so a correctly configured App no longer warns about undeliverable webhook events.
The check previously required pull_request_target (which GitHub never delivers — preloop synthesizes it from the pull_request webhook) and flagged check_run/check_suite as missing even though checks: write auto-subscribes them and GitHub omits them from events.
- Reads events and permissions from the same
GET /appresponse; the warning now separates events tickable now from events needing a permission grant (and installation acceptance) first. - Drops
pull_request_targetfrom the required list and treatscheck_run/check_suiteas satisfied bychecks: write. - Updates docs that published the wrong list; tests now assert required events are real GitHub webhook events instead of deriving from the table under test.
- Drive-by: fixes a
clippy::manual_is_multiple_offailure instore.rsthat breaksjust test-cionmain.
[!NOTE]
Stop warning about undeliverable webhook events by enriching GitHub App subscription model with permissions
- Replaces
read_app_events with read_app_subscription, which fetches both webhook events and permissions from GET /app and returns an AppSubscription struct
- Introduces
TriggerEvent and MissingTriggerEvent structs that model each required event's gating permission and whether write-level permission implicitly delivers it (check_run, check_suite are implicit with checks: write)
warn_missing_trigger_events now computes missing events using explicit subscriptions and implicit delivery, then logs a single consolidated warning with step-by-step guidance grouping events by the permission to grant
- Removes
pull_request_target from the required trigger set (synthesized from pull_request) and updates docs/github-app-api-compat.md and docs/github-app-webhook.md accordingly
- Risk:
read_app_subscription_at now parses a permissions object from GET /app; if GitHub omits or renames permission keys, has_permission/has_write_permission in github_app.rs may misclassify missing events and suppress or misattribute warnings
Macroscope summarized dbb3f38.
Summary by CodeRabbit
-
Bug Fixes
- Improved GitHub App webhook subscription checks by accounting for required permissions.
- Warnings now distinguish missing event subscriptions from events blocked by insufficient permissions.
- Correctly treats check-related events as available when the appropriate write permission is granted.
- Removed unnecessary warnings for
pull_request_target, which is generated from another webhook event.
-
Documentation
- Updated GitHub App webhook and compatibility guidance to reflect subscription and permission requirements.