From 83e62dc6e12630141df7dc5faa5001b6f7f1aa2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Wed, 21 May 2025 16:44:04 +0200 Subject: [PATCH 1/4] Fix double logs on failure --- .../Platform/Modules/Functions/Workers/Builds.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index cbbe6ee9c3..163623241c 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -1218,13 +1218,22 @@ class Builds extends Action $message .= "\n" . $error; } + // Combine with previous logs if deployment got past build process + $previousLogs = ''; + if (!empty($deployment->getAttribute('buildEndedAt', ''))) { + $previousLogs = $deployment->getAttribute('buildLogs', ''); + if (!empty($previousLogs)) { + $message = $previousLogs . "\n" . $message; + } + } + $endTime = DateTime::now(); $durationEnd = \microtime(true); $deployment->setAttribute('buildEndedAt', $endTime); $deployment->setAttribute('buildDuration', \intval(\ceil($durationEnd - $durationStart))); $deployment->setAttribute('status', 'failed'); - $deployment->setAttribute('buildLogs', $deployment->getAttribute('buildLogs', '') . "\n" . $message); + $deployment->setAttribute('buildLogs', $message); $deployment = $dbForProject->updateDocument('deployments', $deploymentId, $deployment); if ($deployment->getInternalId() === $resource->getAttribute('latestDeploymentInternalId', '')) { From d283c820daa4f42c9a83749d35125ae7dc70e9ce Mon Sep 17 00:00:00 2001 From: Khushboo Verma Date: Thu, 22 May 2025 13:34:25 +0530 Subject: [PATCH 2/4] Only load error page for development mode --- app/views/general/error.phtml | 54 ++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/app/views/general/error.phtml b/app/views/general/error.phtml index c6457ce98f..de1c2b6541 100644 --- a/app/views/general/error.phtml +++ b/app/views/general/error.phtml @@ -479,35 +479,37 @@ switch ($type) { -
- -
Error trace
- $traceItem): ?> -
- -
file
-
print($traceItem['file']); ?>
- + +
+ +
Error trace
+ $traceItem): ?> +
+ +
file
+
print($traceItem['file']); ?>
+ - -
line
-
print($traceItem['line']); ?>
- + +
line
+
print($traceItem['line']); ?>
+ - -
function
-
print($traceItem['function']); ?>
- + +
function
+
print($traceItem['function']); ?>
+ - -
args
-
print(\var_export($traceItem['args'], true)); ?>
- -
- -
+ +
args
+
print(\var_export($traceItem['args'], true)); ?>
+ +
+ +
+
From 128dc1d946ab46bdb23127dcc94bc4f77a159139 Mon Sep 17 00:00:00 2001 From: Fabian Gruber Date: Thu, 22 May 2025 09:58:48 +0200 Subject: [PATCH 3/4] fix: send deploymentResourceType in rules verification --- app/controllers/api/proxy.php | 3 ++- src/Appwrite/Platform/Modules/Proxy/Http/Rules/API/Create.php | 2 +- .../Platform/Modules/Proxy/Http/Rules/Function/Create.php | 2 +- .../Platform/Modules/Proxy/Http/Rules/Redirect/Create.php | 2 +- src/Appwrite/Platform/Modules/Proxy/Http/Rules/Site/Create.php | 2 +- src/Appwrite/Platform/Workers/Certificates.php | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/controllers/api/proxy.php b/app/controllers/api/proxy.php index e96f8bfb2c..8c30025551 100644 --- a/app/controllers/api/proxy.php +++ b/app/controllers/api/proxy.php @@ -260,7 +260,8 @@ App::patch('/v1/proxy/rules/:ruleId/verification') // Issue a TLS certificate when domain is verified $queueForCertificates ->setDomain(new Document([ - 'domain' => $rule->getAttribute('domain') + 'domain' => $rule->getAttribute('domain'), + 'domainType' => $rule->getAttribute('deploymentResourceType', $rule->getAttribute('type')), ])) ->trigger(); diff --git a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/API/Create.php b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/API/Create.php index 8ae48ab345..e4d0d2899f 100644 --- a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/API/Create.php +++ b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/API/Create.php @@ -174,7 +174,7 @@ class Create extends Action $queueForCertificates ->setDomain(new Document([ 'domain' => $rule->getAttribute('domain'), - 'domainType' => 'api', + 'domainType' => $rule->getAttribute('deploymentResourceType', $rule->getAttribute('type')), ])) ->trigger(); } diff --git a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Function/Create.php b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Function/Create.php index 15d58c7b29..6c5a87a68d 100644 --- a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Function/Create.php +++ b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Function/Create.php @@ -192,7 +192,7 @@ class Create extends Action $queueForCertificates ->setDomain(new Document([ 'domain' => $rule->getAttribute('domain'), - 'domainType' => 'function', + 'domainType' => $rule->getAttribute('deploymentResourceType', $rule->getAttribute('type')), ])) ->trigger(); } diff --git a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Redirect/Create.php b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Redirect/Create.php index 0ff41e5ac2..d0c9dbbbe3 100644 --- a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Redirect/Create.php +++ b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Redirect/Create.php @@ -180,7 +180,7 @@ class Create extends Action $queueForCertificates ->setDomain(new Document([ 'domain' => $rule->getAttribute('domain'), - 'domainType' => 'redirect', + 'domainType' => $rule->getAttribute('deploymentResourceType', $rule->getAttribute('type')), ])) ->trigger(); } diff --git a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Site/Create.php b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Site/Create.php index f5f6628d68..894c954a32 100644 --- a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Site/Create.php +++ b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Site/Create.php @@ -192,7 +192,7 @@ class Create extends Action $queueForCertificates ->setDomain(new Document([ 'domain' => $rule->getAttribute('domain'), - 'domainType' => 'site', + 'domainType' => $rule->getAttribute('deploymentResourceType', $rule->getAttribute('type')), ])) ->trigger(); } diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index 4e83497cdd..0dce51cb52 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -96,7 +96,7 @@ class Certificates extends Action $log->addTag('domain', $domain->get()); - $domainType = $payload['domainType'] ?? null; + $domainType = $document->getAttribute('domainType'); $this->execute($domain, $domainType, $dbForPlatform, $queueForMails, $queueForEvents, $queueForWebhooks, $queueForFunctions, $queueForRealtime, $log, $certificates, $skipRenewCheck, $plan); } From 67a5192705eefc330e096c2d16024d613d10520e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Thu, 22 May 2025 10:13:12 +0200 Subject: [PATCH 4/4] Fix CNAME validation --- app/controllers/api/proxy.php | 39 +++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/proxy.php b/app/controllers/api/proxy.php index e96f8bfb2c..f07d7755be 100644 --- a/app/controllers/api/proxy.php +++ b/app/controllers/api/proxy.php @@ -214,11 +214,42 @@ App::patch('/v1/proxy/rules/:ruleId/verification') throw new Exception(Exception::RULE_NOT_FOUND); } - $validators = []; - $targetCNAME = new Domain(System::getEnv('_APP_DOMAIN_TARGET_CNAME', '')); - if ($targetCNAME->isKnown() && !$targetCNAME->isTest()) { - $validators[] = new DNS($targetCNAME->get(), DNS::RECORD_CNAME); + $targetCNAME = null; + switch ($rule->getAttribute('type', '')) { + case 'api': + // For example: fra.cloud.appwrite.io + $targetCNAME = new Domain(System::getEnv('_APP_DOMAIN_TARGET_CNAME', '')); + break; + case 'redirect': + // For example: appwrite.network + $targetCNAME = new Domain(System::getEnv('_APP_DOMAIN_SITES', '')); + break; + case 'deployment': + switch ($rule->getAttribute('deploymentResourceType', '')) { + case 'function': + // For example: fra.appwrite.run + $targetCNAME = new Domain(System::getEnv('_APP_DOMAIN_FUNCTIONS', '')); + break; + case 'site': + // For example: appwrite.network + $targetCNAME = new Domain(System::getEnv('_APP_DOMAIN_SITES', '')); + break; + default: + break; + } + // no break + default: + break; } + + $validators = []; + + if (!is_null($targetCNAME)) { + if ($targetCNAME->isKnown() && !$targetCNAME->isTest()) { + $validators[] = new DNS($targetCNAME->get(), DNS::RECORD_CNAME); + } + } + if ((new IP(IP::V4))->isValid(System::getEnv('_APP_DOMAIN_TARGET_A', ''))) { $validators[] = new DNS(System::getEnv('_APP_DOMAIN_TARGET_A', ''), DNS::RECORD_A); }