Repository navigation
fix(git): let webhook URLs use their own origin - #704
Merged
Merged
Conversation
A public edge that forwards only the browser and setup paths cannot serve /api/v1/git/webhooks, and PUBLIC_URL cannot say otherwise without moving the setup callback, browser links and the passkey relying party with it. GIT_WEBHOOK_PUBLIC_URL (chart: gitWebhookPublicUrl) overrides only the origin webhook URLs are built from; unset keeps PUBLIC_URL.
The installer writes the .env a later `docker compose` restart reads, so a GIT_WEBHOOK_PUBLIC_URL exported only for that one run would be lost and the webhook origin would silently fall back to PUBLIC_URL. Also state in the deploy docs that existing webhooks are not moved.
Contributor
There was a problem hiding this comment.
ℹ️ No critical issues — minor documentation and operational notes below.
Reviewed changes
- Webhook origin override in core —
ServerConfig.WebhookPublicURLreadsGIT_WEBHOOK_PUBLIC_URL;Service.WithWebhookBaseURLstores it andwebhookOrigin()falls back topublicURL, soBeginIdentitySetupand per-repositorywebhookURLbuild on the override whileCallbackURL, links, the access-grant callback and the passkey RP stay onPUBLIC_URL. - Return-URL validation unchanged —
sameOriginstill compares againstpublicURL, and the new test pins that a return URL on the webhook origin is refused. - Deployment plumbing — env in Compose/installer/
.envexamples, HelmgitWebhookPublicUrl(values, schema, api Deployment), plusdeploy/README.mdand chart README entries. - Tests — new
TestBeginIdentitySetup_WebhookOriginCanDifferFromTheBrowserOrigin, and the existing repo-webhook registration test now asserts the override URL;go test ./internal/service/git ./internal/configpasses locally.
ℹ️ The chart's bundled gateway and Ingress still serve only publicUrl's host
Setting gitWebhookPublicUrl to a different host publishes webhook URLs that the chart's own edge does not route, so deliveries fail until the operator adds a route for that host.
Technical details
# Chart edge is bound to one host
## Affected sites
- `deploy/helm/paca/templates/_helpers.tpl:197-205` — `paca.gatewaySiteAddress` binds Caddy to `publicUrl`'s host (or `:80` when empty/ingress).
- `deploy/helm/paca/templates/ingress.yaml:19-24` — a single `ingress.host`.
- `deploy/helm/paca/files/Caddyfile:95` — `{$SITE_ADDRESS::80}` site block.
## Required outcome
- The chart README and/or the `gitWebhookPublicUrl` value comment states that the webhook host must reach the API separately (a second Ingress or the operator's own edge), since the bundled gateway/ingress serves only `publicUrl`'s host.
## Open questions for the human
- Should the chart offer a host for this value (e.g. a second Ingress), or is documenting the external-routing requirement enough?deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Migration guidance corrected —
deploy/README.mdnow tells operators to update each GitHub App's webhook URL or unlink/relink each repository and remove stale hooks, rather than pointing at a re-register path the UI does not offer. - Separate-routing requirement documented — the chart README and
values.yamlcomment now state that a distinctgitWebhookPublicUrlhost must be routed to the API separately, since the bundled gateway and Ingress serve only their configured host. - Installer parity —
scripts/install.shlistsGIT_WEBHOOK_PUBLIC_URLin its Network usage block and writes it into the generated.env(scripts/install.sh:887).
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
pikann
approved these changes
Nov 5, 2026
pikann
left a comment
Contributor
There was a problem hiding this comment.
LGTM! Thank you for the contribution! 🚀
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #703.
Problem
A deployment whose public edge forwards only the browser and setup paths cannot receive Git webhooks.
PUBLIC_URLis the one origin for everything — the setupCallbackURL, browser links, comment footers, the access-grant callback and the passkey relying party — so it cannot be pointed at a webhook-only host.Approach
Add
GIT_WEBHOOK_PUBLIC_URL(chart:gitWebhookPublicUrl) as an override for only the origin webhook URLs are built from:ServerConfig.WebhookPublicURL←GIT_WEBHOOK_PUBLIC_URL, empty by default.gitsvc.Service.WithWebhookBaseURL+webhookOrigin(), which falls back topublicURL.setup.go(providerWebhookURL) andrepo_webhooks.go(per-repository hooks).CallbackURL, links and the passkey RP stay onPUBLIC_URL.values.yaml,values.schema.json, README; Compose,.env.example, installer.envand the deploy docs.Providers receive the URL through the SPI fields that already exist (
CallbackURLandWebhookURLare separate), so the plugins need no change.Testing
TestBeginIdentitySetup_WebhookOriginCanDifferFromTheBrowserOrigin: asserts the provider gets the override origin forWebhookURL, keepsPUBLIC_URLforCallbackURL, that the reserved endpoint key matches the published URL, and that a return URL on the webhook origin is still refused.TestRepoWebhook_RegisteredOnLinkAndRemovedWithTheLastLinknow sets the override and asserts the registered hook uses it.webhookOrigin()returningpublicURL, both tests fail with the wrong origin (webhook url = "https://paca.example.com/api/v1/git/webhooks/…", want "https://hooks.example.com/…";ensure webhook = [{… URL:https://paca.example.com/api/v1/git/webhooks/key1}]). Restored → green.go build ./...,go vet,go test ./internal/service/git ./internal/config,git diff --checkclean.helm template -s templates/api/deployment.yamlrendersGIT_WEBHOOK_PUBLIC_URL: ""by default and the value with--set; the schema still type-checks it.bash -n scripts/install.shclean.Migration note
Existing webhooks are not rewritten: an App's hook URL lives in its GitHub settings and is set from the manifest, and re-registering a PAT repository hook PATCHes only a hook whose
config.urlalready matches (otherwise it POSTs a new one and the stale hook stays). After changing the value, edit each App or unlink/relink each repository, then remove the old hooks. Documented indeploy/README.md.Not covered
No live provider setup or delivery was exercised;
golangci-lintis not installed in my environment, so it was not run.