Skip to content

fix(server): match webhook platform by unique host when external_url port differs (v0.9.46) - #134

Merged
Liewzheng merged 1 commit into
mainfrom
fix/platform-host-port-match
Aug 31, 2026
Merged

fix(server): match webhook platform by unique host when external_url port differs (v0.9.46)#134
Liewzheng merged 1 commit into
mainfrom
fix/platform-host-port-match

Conversation

@Liewzheng

Copy link
Copy Markdown
Owner

Problem

Self-hosted GitLab behind a port mapping (external_url = https://host:8443) sends webhook payloads whose project.web_url carries :8443, while the reng Git 平台 entry is configured against the container-reachable https://host. Strict (host, port) matching in find_git_platform_for_url failed, so inbound webhook verification fell through to the empty env runtime and every hook got 403 no verification configured — verified live against a real GitLab EE 19.2.4 instance.

Fix

  • find_git_platform_for_url (INBOUND, webhook verification): after strict host[:port] matching fails, fall back to a host-only match. Hits only when the URL's host identifies exactly one entry with webhook verification credentials — token-only entries neither win the fallback nor make it ambiguous; ambiguous/unknown hosts still yield None. Strict matches keep absolute priority.
  • New find_git_platform_for_url_strict for the OUTBOUND path: REST gitlab_mr token resolution (resolve.rs) stays strict, because a resolved token is sent to the MR URL's host:port and must never flow to an unconfigured port.

Verification

  • cargo fmt --check / cargo clippy --all-targets --all-features: clean
  • cargo test git_platform: 28 passed (7 new tests: strict priority, both fold directions, ambiguity, unknown host, strict never folds, token-only filter × 2)
  • Self-review via review-engine: consensus reached; the one actionable finding (token-only entries could win the fallback) is fixed in this PR
  • Live reproduction on the reporting deployment: signed request to payload URL with :8443 → 403 before; matches after fix

…port differs (v0.9.46)

Self-hosted GitLab behind a port mapping advertises external_url with a
non-default port (e.g. https://host:8443), so webhook payloads carry that
port while the configured Git platform entry targets the reachable URL
(https://host). Strict (host, port) matching failed and inbound
verification fell through to the empty env runtime, answering every hook
with 403 "no verification configured".

find_git_platform_for_url now falls back to a host-only match after strict
matching fails, hitting only when the host identifies exactly one entry
with webhook verification credentials (token-only entries neither win nor
make the fallback ambiguous). Strict matches keep absolute priority.

REST gitlab_mr token resolution switches to the new
find_git_platform_for_url_strict: the resolved token is sent outbound to
the MR URL's host:port and must never flow to an unconfigured port.
@Liewzheng
Liewzheng merged commit c5d5e3a into main Aug 31, 2026
7 checks passed
@Liewzheng
Liewzheng deleted the fix/platform-host-port-match branch August 31, 2026 10:04
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.

1 participant