From fea4994ef050c078efedb48635667acf1dffcb00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Fri, 30 Jan 2026 21:30:00 +0100 Subject: [PATCH] ai review fixes --- app/controllers/api/vcs.php | 2 +- app/controllers/general.php | 2 +- app/http.php | 3 +++ src/Appwrite/Platform/Modules/Compute/Base.php | 2 +- .../Modules/Console/Http/Resources/Get.php | 2 +- .../Modules/Functions/Workers/Builds.php | 2 +- src/Appwrite/Platform/Modules/Proxy/Action.php | 16 +++++++--------- .../Modules/Sites/Http/Deployments/Create.php | 4 ++-- .../Sites/Http/Deployments/Duplicate/Create.php | 2 +- .../Sites/Http/Deployments/Template/Create.php | 2 +- .../e2e/Services/Proxy/ProxyCustomServerTest.php | 1 + 11 files changed, 20 insertions(+), 18 deletions(-) diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index 3a67068f1c..046f10f715 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -341,7 +341,7 @@ $createGitDeployments = function (GitHub $github, string $providerInstallationId $projectId = $project->getId(); // Deployment preview - $sitesDomain = $platform['sitePreviewDomain']; + $sitesDomain = $platform['sitesDomain']; $domain = ID::unique() . "." . $sitesDomain; $ruleId = md5($domain); $previewRuleId = $ruleId; diff --git a/app/controllers/general.php b/app/controllers/general.php index 09bb1a5ff8..3ab59eb870 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -1105,7 +1105,7 @@ App::init() // 5. Create new rule $owner = ''; - // Mark owner as Appwrite if its appwirte-owned domain + // Mark owner as Appwrite if its appwrite-owned domain $appwriteDomains = []; $appwriteDomainEnvs = [ System::getEnv('_APP_DOMAIN_FUNCTIONS_FALLBACK', ''), diff --git a/app/http.php b/app/http.php index d03bbc0355..e23880e943 100644 --- a/app/http.php +++ b/app/http.php @@ -105,6 +105,9 @@ function dispatch(Server $server, int $fd, int $type, $data = null): int $risky = true; } else { foreach (\explode(',', System::getEnv('_APP_DOMAIN_FUNCTIONS')) as $riskyDomain) { + if (empty($riskyDomain)) { + continue; + } if (str_ends_with($domain, $riskyDomain)) { $risky = true; break; diff --git a/src/Appwrite/Platform/Modules/Compute/Base.php b/src/Appwrite/Platform/Modules/Compute/Base.php index 7b844200cb..6f604bae1b 100644 --- a/src/Appwrite/Platform/Modules/Compute/Base.php +++ b/src/Appwrite/Platform/Modules/Compute/Base.php @@ -235,7 +235,7 @@ class Base extends Action ->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', '')); $dbForProject->updateDocument('sites', $site->getId(), $site); - $sitesDomain = $platform['sitePreviewDomain']; + $sitesDomain = $platform['sitesDomain']; $domain = ID::unique() . "." . $sitesDomain; // TODO: (@Meldiron) Remove after 1.7.x migration diff --git a/src/Appwrite/Platform/Modules/Console/Http/Resources/Get.php b/src/Appwrite/Platform/Modules/Console/Http/Resources/Get.php index ae2317e880..717ef6c788 100644 --- a/src/Appwrite/Platform/Modules/Console/Http/Resources/Get.php +++ b/src/Appwrite/Platform/Modules/Console/Http/Resources/Get.php @@ -92,7 +92,7 @@ class Get extends Action $functionsDomains = System::getEnv('_APP_DOMAIN_FUNCTIONS', ''); foreach (\explode(',', $functionsDomains) as $functionsDomain) { - if (empty($sitesDomain)) { + if (empty($functionsDomain)) { continue; } diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index 7473d0eb1f..1c70a1b4ef 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -1037,7 +1037,7 @@ class Builds extends Action // VCS branch $branchName = $deployment->getAttribute('providerBranch'); if (!empty($branchName)) { - $sitesDomain = $platform['sitePreviewDomain']; + $sitesDomain = $platform['sitesDomain']; $branchPrefix = substr($branchName, 0, 16); if (strlen($branchName) > 16) { $remainingChars = substr($branchName, 16); diff --git a/src/Appwrite/Platform/Modules/Proxy/Action.php b/src/Appwrite/Platform/Modules/Proxy/Action.php index 913d9e6a8d..52f40aec00 100644 --- a/src/Appwrite/Platform/Modules/Proxy/Action.php +++ b/src/Appwrite/Platform/Modules/Proxy/Action.php @@ -50,7 +50,7 @@ class Action extends PlatformAction $functionsDomains = System::getEnv('_APP_DOMAIN_FUNCTIONS', ''); foreach (\explode(',', $functionsDomains) as $functionsDomain) { - if (empty($sitesDomain)) { + if (empty($functionsDomains)) { continue; } @@ -67,14 +67,6 @@ class Action extends PlatformAction throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'This domain name is not allowed. Please use a different domain.'); } - if (!empty($sitesDomain)) { - $deniedDomains[] = $sitesDomain; - } - - if (!empty($functionsDomain)) { - $deniedDomains[] = $functionsDomain; - } - $denyListDomains = System::getEnv('_APP_CUSTOM_DOMAIN_DENY_LIST', ''); $denyListDomains = \array_map('trim', explode(',', $denyListDomains)); foreach ($denyListDomains as $denyListDomain) { @@ -141,11 +133,17 @@ class Action extends PlatformAction if ($resourceType === 'function') { // For example: fra.appwrite.run foreach (\explode(',', System::getEnv('_APP_DOMAIN_FUNCTIONS', '')) as $targetCNAME) { + if (empty($targetCNAME)) { + continue; + } $targetCNAMEs[] = new Domain($targetCNAME); } } elseif ($resourceType === 'site') { // For example: appwrite.network foreach (\explode(',', System::getEnv('_APP_DOMAIN_SITES', '')) as $targetCNAME) { + if (empty($targetCNAME)) { + continue; + } $targetCNAMEs[] = new Domain($targetCNAME); } } elseif ($ruleType === 'api') { diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php index c2420aa223..6d6b599ed7 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php @@ -274,7 +274,7 @@ class Create extends Action ->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', '')); $dbForProject->updateDocument('sites', $site->getId(), $site); - $sitesDomain = $platform['sitePreviewDomain']; + $sitesDomain = $platform['sitesDomain']; $domain = ID::unique() . "." . $sitesDomain; // TODO: (@Meldiron) Remove after 1.7.x migration @@ -344,7 +344,7 @@ class Create extends Action ->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', '')); $dbForProject->updateDocument('sites', $site->getId(), $site); - $sitesDomain = $platform['sitePreviewDomain']; + $sitesDomain = $platform['sitesDomain']; $domain = ID::unique() . "." . $sitesDomain; $ruleId = md5($domain); $authorization->skip( diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php index bb0c007850..1d60c6776c 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php @@ -145,7 +145,7 @@ class Create extends Action $dbForProject->updateDocument('sites', $site->getId(), $site); // Preview deployments for sites - $sitesDomain = $platform['sitePreviewDomain']; + $sitesDomain = $platform['sitesDomain']; $domain = ID::unique() . "." . $sitesDomain; // TODO: (@Meldiron) Remove after 1.7.x migration diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Template/Create.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Template/Create.php index 2e079a057b..e36bed94bc 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Template/Create.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Template/Create.php @@ -189,7 +189,7 @@ class Create extends Base ->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', '')); $dbForProject->updateDocument('sites', $site->getId(), $site); - $sitesDomain = $platform['sitePreviewDomain']; + $sitesDomain = $platform['sitesDomain']; $domain = ID::unique() . "." . $sitesDomain; // TODO: (@Meldiron) Remove after 1.7.x migration diff --git a/tests/e2e/Services/Proxy/ProxyCustomServerTest.php b/tests/e2e/Services/Proxy/ProxyCustomServerTest.php index 279b2a7077..be0b89b404 100644 --- a/tests/e2e/Services/Proxy/ProxyCustomServerTest.php +++ b/tests/e2e/Services/Proxy/ProxyCustomServerTest.php @@ -312,6 +312,7 @@ class ProxyCustomServerTest extends Scope $rule = $this->getRule($wildcardRuleId); $this->assertSame(200, $rule['headers']['status-code']); $this->assertSame('verified', $rule['body']['status']); + $this->cleanupRule($wildcardRuleId); } $rules = $this->listRules([