From d505ca68330f20bd400f3f96e1b26da4834cd330 Mon Sep 17 00:00:00 2001 From: Hemachandar Date: Sun, 8 Feb 2026 12:23:29 +0530 Subject: [PATCH] Better logs for DNS failures --- .../Proxy/Http/Rules/Verification/Update.php | 32 +++++++++++-------- .../Platform/Workers/Certificates.php | 6 +++- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Verification/Update.php b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Verification/Update.php index 7266e8d183..ee0d99bacb 100644 --- a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Verification/Update.php +++ b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Verification/Update.php @@ -88,26 +88,30 @@ class Update extends Action try { $this->verifyRule($rule, $log); - // Reset logs and status for the rule - $rule = $dbForPlatform->updateDocument('rules', $rule->getId(), new Document([ - 'logs' => '', - 'status' => RULE_STATUS_CERTIFICATE_GENERATING, - ])); - - $certificateId = $rule->getAttribute('certificateId', ''); - // Reset logs for the associated certificate. - if (!empty($certificateId)) { - $certificate = $dbForPlatform->updateDocument('certificates', $certificateId, new Document([ - 'logs' => '', - ])); - } } catch (Exception $err) { + $date = \date('H:i:s'); + $logs = "\033[90m[{$date}] \033[97m" . $err->getMessage() . "\033[0m\n"; + $logs .= "\033[90m[{$date}] \033[97mVerify your DNS records are correct and retry.\033[0m\n"; + $logs .= "\033[90m[{$date}] \033[97mAlternatively, we'll periodically retry verification.\033[0m\n"; $dbForPlatform->updateDocument('rules', $rule->getId(), new Document([ - '$updatedAt' => DateTime::now(), + 'logs' => $logs, ])); throw $err; } + // Reset logs and status for the rule + $rule = $dbForPlatform->updateDocument('rules', $rule->getId(), new Document([ + 'logs' => '', + 'status' => RULE_STATUS_CERTIFICATE_GENERATING, + ])); + $certificateId = $rule->getAttribute('certificateId', ''); + // Reset logs for the associated certificate. + if (!empty($certificateId)) { + $certificate = $dbForPlatform->updateDocument('certificates', $certificateId, new Document([ + 'logs' => '', + ])); + } + // Issue a TLS certificate when DNS verification is successful $queueForCertificates ->setDomain(new Document([ diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index a726647ec4..eec1369ff5 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -177,7 +177,11 @@ class Certificates extends Action Console::success('Domain verification succeeded.'); } catch (AppwriteException $err) { Console::warning('Domain verification failed: ' . $err->getMessage()); - $rule->setAttribute('logs', $err->getMessage()); + $date = \date('H:i:s'); + $logs = "\033[90m[{$date}] \033[97m" . $err->getMessage() . "\033[0m\n"; + $logs .= "\033[90m[{$date}] \033[97mVerify your DNS records are correct and retry.\033[0m\n"; + $logs .= "\033[90m[{$date}] \033[97mAlternatively, we'll periodically retry verification and update the status.\033[0m\n"; + $rule->setAttribute('logs', $logs); } finally { // Update rule and emit events $this->updateRuleAndSendEvents($rule, $dbForPlatform, $queueForEvents, $queueForWebhooks, $queueForFunctions, $queueForRealtime);