Skip to content

fix(service): find why webhook deliveries get HTTP 403 #5017

Closed

Description

@dan-petty

Problem Description

22 of the 60 newest deliveries of the repository hook (2026-11-12 07:56-08:09Z) got HTTP 403 with the response header Server: cloudflare (read on 2026-11-12). GitHub does not send a failed delivery again, and the redelivery item #4560 is not built. The alert RoadmapServiceWebhooksRejected counts only the refusals of the route behind Traefik (k8s/README.md, Webhook route), so it cannot see a refusal at the Cloudflare edge. Each event step of this plan (pull_request due marks, #4413, #4416, #4415) needs the deliveries. A search found no open issue for it.

Reproduction Steps

  1. Run uv run devops gh api repos/dan-petty/devops-cli/hooks and note the id of the repository hook.
  2. Run uv run devops gh api repos/dan-petty/devops-cli/hooks/<hook-id>/deliveries --jq '[.[]|select(.status_code==403)]|length'.
  3. Read one failed delivery with uv run devops gh api repos/dan-petty/devops-cli/hooks/<hook-id>/deliveries/<delivery-id> and look at the response headers.

Expected vs Actual Behavior

Expected: each signed delivery reaches the webhook route of the Service. The route answers 2xx, or 401 for a bad signature, or 429 above its rate limit.

Actual: 22 of the 60 newest deliveries (2026-11-12 07:56-08:09Z) got HTTP 403 with the response header Server: cloudflare. The alert RoadmapServiceWebhooksRejected does not fire, because it counts only the refusals behind Traefik.

Proposed Fix

  1. Check the premise first. Read the failed deliveries (time, event, status code, response headers) with uv run devops gh api repos/<owner>/<name>/hooks/<id>/deliveries. Read the Access applications and policies of hooks. with devops cloudflare access status --json and devops cloudflare access policies <app-id>. Find the rule that answers 403: an Access application with no bypass for the path, a WAF rule or a rate rule.
  2. When the cause is in the repository (a manifest, an OpenTofu file or a setting), fix it at the source. When the fix is a change of an Access or WAF rule at the edge, stop and give the evidence to the owner (decision O3).
  3. Add a check that fails when the problem comes back: the metrics row reads the newest deliveries of each hook of service.repos and sets the gauge devops_cli_service_webhook_delivery_failures{code}, and a Prometheus rule alerts when more than 5 deliveries fail in 15 minutes.
  4. Change k8s/README.md (Webhook route, setup step 6) to name the edge check.

Open tool: the GitHub hook deliveries API; no new tool.

Cost: about 0.5M tokens and 0.5 agent-day.

Acceptance Criteria

  • After the fix, uv run devops gh api repos/dan-petty/devops-cli/hooks/<hook-id>/deliveries --jq '[.[]|select(.status_code==403)]|length' gives 0 for the deliveries after the fix time.
  • A unit test reads a fake deliveries page with two 403 answers and sets the gauge to 2.
  • promtool test rules passes for the new alert.

Dependencies

Pre-Submission Checklist

Source: #5014

Proposed design

Problem statement

22 of the 60 newest deliveries of the repository hook got HTTP 403 with Server: cloudflare on 2026-11-12 07:56-08:09Z. GitHub does not send a failed delivery again, so each event step of the roadmap loses deliveries. The alert RoadmapServiceWebhooksRejected counts only the refusals of the route behind Traefik, so it cannot see a refusal at the edge. This change reads the deliveries of each hook, sets a gauge by status code, adds an alert, and names the edge check in the documentation. The search for the edge rule that answers 403 goes to a new issue, because only the owner changes the Cloudflare configuration.

Acceptance criteria

Requirement: The Service reads the deliveries of each hook

The Service SHALL read the newest deliveries of each repository hook of service.repos in its metrics round.

Scenario: A repository with two hooks

  • WHEN The metrics row runs for a repository whose two hooks both answer a deliveries page.
  • THEN The row sends one GET /repos/<owner>/<name>/hooks/<id>/deliveries request for each hook, and devops_cli_github_requests_total counts each under row="metrics".

Requirement: The installation token names the webhooks read permission

The installation token that the Service mints SHALL name the webhooks read permission.

Scenario: The permissions of a minted token

  • WHEN The Service mints an installation token for a repository.
  • THEN The mint request names webhooks: read with the permissions that the Service already names.

Requirement: The gauge counts the failed deliveries by code

The metrics row SHALL set devops_cli_service_webhook_delivery_failures{repo,code} to the number of deliveries of the newest page of each hook whose status code is 400 or above.

Scenario: A page with two 403 answers and one 202 answer

  • WHEN The row reads a fake deliveries page that holds two 403 answers and one 202 answer.
  • THEN The gauge holds the value 2 for code="403" and no series for a code below 400.

Requirement: A burst of failed deliveries alerts

A rule of the group roadmap-service-webhooks SHALL fire when a repository has more than 5 failed deliveries.

Scenario: Six 403 deliveries in the newest page

  • WHEN promtool test rules evaluates the group with devops_cli_service_webhook_delivery_failures{code="403",repo="dan-petty/devops-cli"} at 6.
  • THEN The rule fires with severity="warning" and names the repository, and it stays quiet on the same series at 5.

Requirement: The documentation names the edge check

k8s/README.md SHALL name the deliveries check in the Webhook route section and in the Alerts table.

Scenario: The Webhook route section and the Alerts table

  • WHEN A test reads k8s/README.md.
  • THEN The Webhook route section holds the deliveries command and the Server: cloudflare header, and the Alerts table holds the row of the new rule.

Existing Tool Considered

No alternatives check has run. The GitHub REST API for repository webhook deliveries covers the need, and the repository reaches it with uv run devops gh api repos/<owner>/<name>/hooks/<id>/deliveries (Reproduction steps). It lacks a view of the Cloudflare edge: it gives the status code and the response header Server: cloudflare, and not the Access, WAF or rate rule that answered. The change writes no client for the API. It adds the metric, the rule, the tests and the documentation, at about 0.5M tokens and 0.5 agent-day (Cost).

Key questions

  • Which row of the Service reads the deliveries of each hook?: The metrics row of the status lane reads each hook of service.repos once in its round. It already reads GitHub in the round and needs no clone. (best practice) [sources: k8s/README.md]
    • Chosen: The metrics row of the status lane. It reads GitHub in each round and needs no clone.
    • Rejected: A new row of the status lane. It adds a row, an interval and a lane slot for one request for each hook.
    • Rejected: The pr_conflicts row. That row judges pull requests and reads no hook.
  • Is the delivery count a gauge of the newest page, or a counter of new deliveries?: The Service sets the gauge devops_cli_service_webhook_delivery_failures{repo,code} from the newest deliveries page of each hook. A counter would count the same delivery again in each round, unless the Service kept a fifth state file. (best practice) [sources: k8s/README.md]
    • Chosen: A gauge of the newest page. It needs no state file, and the page holds the time, the event and the status code of each delivery.
    • Rejected: A counter with a record of the counted delivery ids. It adds a state record, its write failure and its devops_cli_service_state_unkept value.
  • Which status codes does the gauge count?: Each status code from 400 up, in its own series. (best practice) [sources: k8s/README.md]
    • Chosen: Each code from 400 up. The route answers 2xx for a good delivery, and a 401, 413, 415, 429 or 503 is a fault that the runbook names.
    • Rejected: 403 only. It hides a bad secret, a body above the cap and the rate limit.
    • Rejected: Each code that is not 2xx. A 3xx is no refusal, and it adds a series with no meaning.
  • How does the Service read the deliveries of a hook?: With the installation token of the GitHub App, with webhooks: read added to the permissions that the Service names. The App already grants read and write on every repository permission, so the mint succeeds. (best practice) [sources: k8s/README.md, docs/adr/0015-roadmap-jobs-act-as-a-github-app-on-the-personal-account.md]
    • Chosen: The App token with webhooks: read. It keeps one credential, and the installation token takes one permission more.
    • Rejected: A token from the owner's keyring. It puts a second credential in the cluster, and the owner's token acts as the owner.
    • Rejected: The last_response of each hook. It holds one delivery, so it cannot count a burst.
  • Which rule group and which test file hold the webhook alerts?: The rule group roadmap-service-webhooks in k8s/monitoring/prometheus-values.yaml. The promtool cases are in tests/fixtures/prometheus_rules/roadmap_service_webhooks_tests.yaml, run by tests/prometheus/test_k8s_monitoring_alerting.py. [sources: k8s/monitoring/prometheus-values.yaml:848, tests/fixtures/prometheus_rules/roadmap_service_webhooks_tests.yaml, tests/prometheus/test_k8s_monitoring_alerting.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    on Nov 12, 2026
  2. added
    type/bug
    scope/service
    status/new
    value/high
    effort/medium
    on Nov 12, 2026
  3. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor
    • Priority: P1-High. 22 of 60 deliveries fail and multiple event steps depend on them, so the failure blocks active work.
    • Related: feat(service): redeliver webhook deliveries that failed #4560, which asks for a different change. Both concern failed webhook deliveries, but the candidate finds and fixes the 403 cause while #4560 builds a redelivery mechanism.
  4. added
    priority/p1-high
    on Nov 12, 2026
  5. removed
    priority/p1-high
    on Nov 12, 2026
  6. devops-cli-service commented on Nov 12, 2026

    @devops-cli-service
    Contributor
    • Priority: P1-High. The 403 refusals lose webhook deliveries and block the event steps of #5014.
    • Related: feat(service): redeliver webhook deliveries that failed #4560, which asks for a different change. Both items concern failed webhook deliveries, but #4560 redelivers them and this item finds the 403 cause and adds an alert.
  7. added
    priority/p1-high
    on Nov 12, 2026
  8. added
    owner/agent
    on Nov 12, 2026
  9. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    Premise check: Cloudflare Access refuses the deliveries from 3 new GitHub hook ranges

    The cause is at the edge, not in the repository. A change of an Access policy is owner decision O3, so I did not change it. The pull request for this issue adds only the edge check (steps 3 and 4).

    Evidence (read on 2026-11-12, read-only commands)

    1. The deliveries. uv run devops gh api 'repos/dan-petty/devops-cli/hooks/692250036/deliveries?per_page=100' at 10:18Z: 39 of the 100 newest deliveries (10:04-10:17Z) got HTTP 403. The 403 answers come from all events and actions (issues.labeled, issues.edited, pull_request.opened and others), and they mix with 202 answers in the same seconds. So the cause is not one event and not a burst.
    2. The answer of a refused delivery. uv run devops gh api repos/dan-petty/devops-cli/hooks/692250036/deliveries/<id> for 6 of the 403 deliveries: each answer has the headers Server: cloudflare, Cf-Access-Domain: hooks.<domain> and the same Cf-Access-Aud, and the body is the page Error ・ Cloudflare Access. The 403 answers take 0.08-0.3 s. An accepted delivery has no Cf-Access-* header, has X-Devops-Version from the Service, and its body is {"status":"accepted"}. So Cloudflare Access refuses the request before it gets to the tunnel. It is not a WAF rule or a rate rule.
    3. The Access application. devops cloudflare access status --json: the application GitHub Webhooks - Roadmap Service covers hooks.<domain>/webhooks/github. devops cloudflare access policies <app-id> gives two Bypass policies and no Allow policy:
      • gh-hooks-public-ips: 6 ranges, 192.30.252.0/22, 185.199.108.0/22, 140.82.112.0/20, 143.55.64.0/20, 2a0a:a440::/29, 2606:50c0::/32.
      • homelab-public-ip-bypass: the public address of the home network.
    4. GitHub's hook ranges. uv run devops gh api meta --jq .hooks gives 9 ranges. These 3 are not in gh-hooks-public-ips: 9.234.98.160/28, 9.234.98.176/28, 9.234.106.48/28. A delivery from one of them matches no Bypass policy and no Allow policy, so Access answers 403.
    5. No source in the repository. No manifest, OpenTofu file or setting holds these ranges. devops cloudflare access sync makes only the policy homelab-public-ip-bypass. A person made gh-hooks-public-ips in the dashboard. Setup step 6 of k8s/README.md says "add a Bypass application" and names no ranges.
    6. GitHub's advice. About GitHub's IP addresses: "We make changes to our IP addresses from time to time." and "We do not recommend allowing by IP address", and if you do, "we strongly encourage regular monitoring of our API."

    Decision O3 for the owner

    • Recommended: change gh-hooks-public-ips to include Everyone on the path hooks.<domain>/webhooks/github only. The route keeps its own controls: the HMAC signature check (401), the Traefik limit of 60 requests a minute (429) and the alert RoadmapServiceWebhooksRejected. GitHub can change its ranges again with no notice.
    • Other option: add the 3 ranges above to gh-hooks-public-ips. Then compare the policy with uv run devops gh api meta --jq .hooks each time the new alert fires.

    After the change, this command must give 0 (put the change time in place of <time>, for example 2026-11-12T12:00:00Z): uv run devops gh api 'repos/dan-petty/devops-cli/hooks/692250036/deliveries?per_page=100' --jq '[.[]|select(.status_code==403 and .delivered_at > "<time>")]|length'. Note: gh's --jq rounds the delivery IDs, so to read one delivery, take its ID from the output without --jq.

  10. added
    status/ready
    and removed
    status/new
    on Nov 12, 2026
  11. devops-cli-service commented on Nov 12, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 87ae9ee (see proposed design in issue body).

    Moved to new items: #5035.

  12. added
    status/in-review
    and removed
    status/ready
    on Nov 12, 2026
  13. removed
    status/in-review
    owner/agent
    on Nov 12, 2026
  14. devops-cli-service commented on Nov 12, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-12 12:40 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p1-highscope/servicesource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions