Repository navigation
Description
Split from #4560.
Problem: the roadmap Service receives the GitHub App webhook today (one secret, service.github_app.webhook_secret, #4417), but docs/CLUSTER.md:136 and the onboarding docs still describe repository hooks, and a failed delivery of such a hook has no redelivery code. The App hook path of #4560 covers only the App webhook.
Why deferred: the repository hook redelivery needs a token with the repository Webhooks write permission, and the Service token holds Webhooks read only (docs/CLUSTER.md:42). Only a person changes that App permission. The App hook path can ship first.
Acceptance criteria:
- The row lists failed deliveries of each repository hook with
GET /repos/{owner}/{repo}/hooks/{hook_id}/deliveries. - The row sends one redelivery request for each failed delivery with no later success through
POST /repos/{owner}/{repo}/hooks/{hook_id}/deliveries/{delivery_id}/attempts. - The row uses a token with the repository Webhooks write permission.
- The row skips a delivery older than 3 days.
- A test with a faked hook delivery list proves the selection and the request.
- A live proof after the merge shows one redelivered repository hook delivery with its new status.
Proposed design
Problem statement
The Service reads failed repository webhook deliveries with a read-only token and cannot redeliver them. It must select each failed delivery that has no later success and is younger than 3 days. It must send one redelivery request for each selected delivery. The redelivery needs the GitHub App permission Webhooks write. Only a person grants that permission. The code can merge before the grant, and the live proof waits for the grant.
Acceptance criteria
Requirement: List failed hook deliveries
The Service SHALL list the deliveries of each active repository hook with GET /repos/{owner}/{repo}/hooks/{hook_id}/deliveries.
Scenario: Read failed deliveries
- WHEN The redelivery step runs for a repository with an active hook.
- THEN The step pages the hook deliveries newest first and keeps each delivery whose status code is below 200 or at least 300.
Requirement: Skip a delivery with a later success
The Service SHALL select a failed delivery only when no later delivery of the same hook, event and action has a 2xx status code.
Scenario: Later success of the same event
- WHEN A failed delivery has a later delivery of the same hook, event and action with a 2xx status code.
- THEN The step sends no redelivery request for that failed delivery.
Requirement: Redeliver a selected delivery
The Service SHALL send one POST /repos/{owner}/{repo}/hooks/{hook_id}/deliveries/{delivery_id}/attempts request for each selected failed delivery.
Scenario: Send one redelivery request
- WHEN A failed delivery has no later success and is younger than 3 days.
- THEN The step sends exactly one redelivery request for that delivery and no request for an unselected delivery.
Requirement: Record an accepted redelivery
The Service SHALL record each accepted redelivery request in Valkey under a key for the repository and delivery ID with a TTL of 3 days.
Scenario: Repeat run for a redelivered delivery
- WHEN The redelivery step runs again and Valkey holds the delivery ID.
- THEN The step sends no second redelivery request for that delivery ID.
Requirement: Skip an old delivery
The Service MUST skip a failed delivery whose delivered_at is older than 3 days.
Scenario: Old failed delivery
- WHEN A failed delivery has no later success and its
delivered_atis older than 3 days. - THEN The step sends no redelivery request for that delivery.
Requirement: Use the Service installation token
The Service MUST send the redelivery request with the existing installation token of the Service.
Scenario: Redelivery uses the Service token
- WHEN The step sends a redelivery request.
- THEN The request uses the Service installation token and no new secret.
Requirement: Report a missing Webhooks write permission
The Service MUST stop the redelivery step with a typed permission error when the GitHub API refuses the request for missing Webhooks write permission.
Scenario: Token lacks Webhooks write
- WHEN The GitHub API answers the redelivery request with HTTP 403 because the token lacks Webhooks write.
- THEN The step stops with a typed permission error, sends no retry and names the missing App permission.
Requirement: Pending a person after the merge
A person SHALL grant the App Webhooks write permission and SHALL show one redelivered repository hook delivery after the merge.
Scenario: Live redelivery proof
- WHEN A person grants the permission and runs
uv run devops gh api repos/<owner>/<repo>/hooks/<hook_id>/deliveries/<delivery_id>for the redelivered delivery. - THEN The command shows the new 2xx status of the redelivered delivery.
Existing Tool Considered
No alternatives check has run. Use gidgethub, the open and maintained GitHub API client that ADR 0006 mandates, for the authenticated REST calls. Use the existing Valkey store for the one-attempt key. gidgethub covers the list and redelivery endpoints, and Valkey covers the shared state. gidgethub does not grant the App permission: the Service token needs Webhooks write, and only a person grants it. The change adds no new HTTP client or state store.
Key questions
- Which HTTP client should call the repository hook delivery endpoints?: Use gidgethub. ADR 0006 makes it the GitHub session of the project. The redelivery code adds calls to that session and adds no HTTP client. (best practice) [sources: docs/CLUSTER.md]
- Chosen: gidgethub. ADR 0006 mandates it for GitHub requests, and it covers authenticated REST calls.
- Rejected: httpx. It adds a second authenticated GitHub client and repeats token and retry handling.
- Rejected: A new client. It builds code that gidgethub already provides.
- Where should the redelivery run?: Run it in the existing metrics row that reads failed repository hook deliveries. That row pages the deliveries, has the Service installation token, and runs every 13 minutes by default. (best practice) [sources: docs/CLUSTER.md]
- Chosen: Extend the metrics row. It already reads the failed deliveries and has the token, so the change needs no second read.
- Rejected: Add a new Service row. It repeats the hook and delivery reads and adds a second schedule to keep.
- Rejected: A manual command. The issue requires automatic redelivery, not an operator command.
- How does the row decide that a failed delivery has no later success?: It checks later deliveries of the same hook, event and action for a 2xx status code. A later success of a different event or action does not clear the failed delivery. (best practice) [sources: docs/CLUSTER.md]
- Chosen: Compare the same event and action. A delivery carries one event and action, so only a later delivery of the same event and action replaces it.
- Rejected: Compare the whole hook. A success of another event does not prove that this delivery reached the consumer.
- Rejected: Use a Valkey dedupe key only. The delivery list already holds the later success, so the key alone does not select the delivery.
- Which permission does the redelivery request need?: The repository Webhooks write permission. The Service token has Webhooks read only today, and only a person changes the App permission. [sources: docs/CLUSTER.md:42, AGENTS.md]
- What should the row do when the token lacks Webhooks write?: Stop the row with a typed permission error and no retry. Name the missing App permission in the error. A person must grant the permission before the live proof. (best practice) [sources: AGENTS.md, docs/CLUSTER.md]
- Chosen: Stop with a typed error. Only a person can change the permission, so a retry cannot repair the cause.
- Rejected: Retry the request. It repeats a request that the API refuses until a person changes the App permission.
- Rejected: Skip the delivery. It hides the missing permission and leaves failed deliveries with no redelivery.
- How does the row send only one redelivery request for one failed delivery?: It writes a Valkey key for the repository and delivery ID with a TTL of 3 days after the GitHub API accepts the request. A later run finds the key and skips the delivery. (best practice) [sources: docs/CLUSTER.md]
- Chosen: Write a Valkey key with a 3-day TTL. The Service already uses Valkey for shared state, and the TTL matches the 3-day window.
- Rejected: Use only the delivery list. A failed redelivery stays failed, so the row would send the request again on each run.
- Rejected: Use an in-memory set. A new pod loses the set, so the row would send the request again.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
devops-cli-service commentedon Nov 29, 2026
Both deal with failed repository webhook deliveries, but #5017 finds the cause of HTTP 403 refusals while the candidate builds the redelivery code for those failures.devops-cli-service commentedon Nov 29, 2026
Next step: the alternatives check records a verdict. See the section Proposed design of the body.