From cdb400b538590318a564f65eeef8e5d002cba1a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Thu, 11 Sep 2025 15:02:44 +0200 Subject: [PATCH] AI review bug fixing --- src/Appwrite/Network/Validator/DNS.php | 16 ++++++++-------- src/Appwrite/Platform/Modules/Proxy/Base.php | 4 ++-- .../Modules/Proxy/Http/Rules/API/Create.php | 4 ++-- .../Modules/Proxy/Http/Rules/Function/Create.php | 4 ++-- .../Modules/Proxy/Http/Rules/Redirect/Create.php | 4 ++-- .../Modules/Proxy/Http/Rules/Site/Create.php | 4 ++-- .../Proxy/Http/Rules/Verification/Update.php | 1 + src/Appwrite/Platform/Workers/Certificates.php | 2 +- 8 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/Appwrite/Network/Validator/DNS.php b/src/Appwrite/Network/Validator/DNS.php index 1691f2a962..5d8961ca77 100644 --- a/src/Appwrite/Network/Validator/DNS.php +++ b/src/Appwrite/Network/Validator/DNS.php @@ -66,9 +66,9 @@ class DNS extends Validator $msg = "Domain {$this->domain} has {$this->count} {$this->type} {$record} with wrong {$value}: {$recordValuesVerbose}."; if ($this->type === self::RECORD_CAA) { - $msg .= ' You can resolve this by adding our record too (recommended), or removing all other records.'; + $msg .= ' You can resolve this by adding our record (recommended), or removing all other records.'; } elseif ($this->type === self::RECORD_A || $this->type === self::RECORD_AAAA || $this->type === self::RECORD_CNAME) { - $msg .= ' You can resolve this by changing the record to haveour value.'; + $msg .= ' You can resolve this by changing the record to have our value.'; } return $msg; @@ -90,16 +90,16 @@ class DNS extends Validator */ public function isValid(mixed $value): bool { - $this->count = 0; - $this->domain = \is_string($value) ? $value : \strval($value); - $this->reason = self::FAILURE_REASON_UNKNOWN; - $this->recordValues = []; - - if (!is_string($value)) { + if (!\is_string($value)) { $this->reason = self::FAILURE_REASON_INTERNAL; return false; } + $this->count = 0; + $this->domain = \strval($value); + $this->reason = self::FAILURE_REASON_UNKNOWN; + $this->recordValues = []; + $dns = new Client($this->dnsServer); try { diff --git a/src/Appwrite/Platform/Modules/Proxy/Base.php b/src/Appwrite/Platform/Modules/Proxy/Base.php index 79e75e8da6..0d3e79b9b7 100644 --- a/src/Appwrite/Platform/Modules/Proxy/Base.php +++ b/src/Appwrite/Platform/Modules/Proxy/Base.php @@ -35,7 +35,8 @@ class Base extends Action if (!\is_null($log)) { $log->addExtra('dnsTimingCaa', \strval(\microtime(true) - $validationStart)); $log->addTag('dnsDomain', $domain->get()); - $error = $validator->getDescription(); + + $error = $validator->getLogs(); $log->addExtra('dnsResponse', \is_array($error) ? \json_encode($error) : \strval($error)); } @@ -122,7 +123,6 @@ class Base extends Action $errors[] = $validator->getLogs(); } } - $error = \implode("\n", $errors); $log->addExtra('dnsResponse', \is_array($error) ? \json_encode($error) : \strval($error)); } 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 9114a6bdb9..69645bb6fb 100644 --- a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/API/Create.php +++ b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/API/Create.php @@ -161,10 +161,10 @@ class Create extends Base 'region' => $project->getAttribute('region') ]); - if ($status === 'created') { + if ($rule->getAttribute('status', '') === 'created') { try { self::verifyRule($rule, $log); - $status = 'verifying'; + $rule->setAttribute('status', 'verifying'); } catch (Exception $err) { $rule->setAttribute('verificationLogs', $err->getMessage()); } 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 622e5e4b74..c209f4474d 100644 --- a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Function/Create.php +++ b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Function/Create.php @@ -182,10 +182,10 @@ class Create extends Base 'region' => $project->getAttribute('region') ]); - if ($status === 'created') { + if ($rule->getAttribute('status', '') === 'created') { try { self::verifyRule($rule, $log); - $status = 'verifying'; + $rule->setAttribute('status', 'verifying'); } catch (Exception $err) { $rule->setAttribute('verificationLogs', $err->getMessage()); } 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 375d1d6c44..4a343eab4e 100644 --- a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Redirect/Create.php +++ b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Redirect/Create.php @@ -188,10 +188,10 @@ class Create extends Base 'region' => $project->getAttribute('region') ]); - if ($status === 'created') { + if ($rule->getAttribute('status', '') === 'created') { try { self::verifyRule($rule, $log); - $status = 'verifying'; + $rule->setAttribute('status', 'verifying'); } catch (Exception $err) { $rule->setAttribute('verificationLogs', $err->getMessage()); } 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 192c4d46d3..3d8940154b 100644 --- a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Site/Create.php +++ b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Site/Create.php @@ -182,10 +182,10 @@ class Create extends Base 'region' => $project->getAttribute('region') ]); - if ($status === 'created') { + if ($rule->getAttribute('status', '') === 'created') { try { self::verifyRule($rule, $log); - $status = 'verifying'; + $rule->setAttribute('status', 'verifying'); } catch (Exception $err) { $rule->setAttribute('verificationLogs', $err->getMessage()); } 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 b09f456a8c..f376e8211f 100644 --- a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Verification/Update.php +++ b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Verification/Update.php @@ -87,6 +87,7 @@ class Update extends Base $rule = $rule->setAttribute('verificationLogs', ''); } catch (Exception $err) { $rule = $rule->setAttribute('verificationLogs', $err->getMessage()); + $dbForPlatform->updateDocument('rules', $rule->getId(), $rule); throw $err; } diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index 8e51e5e8ba..5064d65545 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -94,7 +94,7 @@ class Certificates extends Action $domainType = $document->getAttribute('domainType'); $skipRenewCheck = $payload['skipRenewCheck'] ?? false; - $action = $payload['action'] ?? []; + $action = $payload['action'] ?? Certificate::ACTION_GENERATION; $verificationDomainFunction = $payload['verificationDomainFunction'] ?? null; $verificationDomainApi = $payload['verificationDomainApi'] ?? null;