From e42fe21ff9884ff0061d845404e11ab0da380984 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 28 May 2026 23:14:26 +1200 Subject: [PATCH] test: gate webhook host validation to production env Webhook E2E tests use the docker service name request-catcher-webhook as the target; that hostname does not resolve via standard DNS, so the new PublicHostname check rejects it. Same env gate Appwrite already uses elsewhere. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/Appwrite/Platform/Workers/Webhooks.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Webhooks.php b/src/Appwrite/Platform/Workers/Webhooks.php index 68e70dfeda..48f12d3ee9 100644 --- a/src/Appwrite/Platform/Workers/Webhooks.php +++ b/src/Appwrite/Platform/Workers/Webhooks.php @@ -103,11 +103,13 @@ class Webhooks extends Action $url = \rawurldecode($webhook->getAttribute('url')); - $host = \parse_url($url, PHP_URL_HOST) ?? ''; - $hostnameValidator = new PublicHostname(); - if (!$hostnameValidator->isValid($host)) { - $this->errors[] = 'Webhook target ' . $host . ' rejected: ' . $hostnameValidator->getDescription(); - return; + if (System::getEnv('_APP_ENV', 'development') === 'production') { + $host = \parse_url($url, PHP_URL_HOST) ?? ''; + $hostnameValidator = new PublicHostname(); + if (!$hostnameValidator->isValid($host)) { + $this->errors[] = 'Webhook target ' . $host . ' rejected: ' . $hostnameValidator->getDescription(); + return; + } } $signatureKey = $webhook->getAttribute('signatureKey');