An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix(server): enhance error handling in server patch check notifications
Andras Bacsaie005f1c83898
diff --git a/app/Jobs/ServerPatchCheckJob.php b/app/Jobs/ServerPatchCheckJob.phpindex c88770d3a7..370ce86f4c 100644--- a/app/Jobs/ServerPatchCheckJob.php+++ b/app/Jobs/ServerPatchCheckJob.php@@ -31,7 +31,7 @@ class ServerPatchCheckJob implements ShouldBeEncrypted, ShouldQueuepublic function handle(): void{try {- if ($this->server->isFunctional() === false) {+ if ($this->server->serverStatus() === false) {return;}@@ -44,6 +44,8 @@ class ServerPatchCheckJob implements ShouldBeEncrypted, ShouldQueue$patchData = CheckUpdates::run($this->server);if (isset($patchData['error'])) {+ $team->notify(new ServerPatchCheck($this->server, $patchData));+return; // Skip if there's an error checking for updates}diff --git a/app/Notifications/Server/ServerPatchCheck.php b/app/Notifications/Server/ServerPatchCheck.phpindex 8453e0dd6f..1686a6f37c 100644--- a/app/Notifications/Server/ServerPatchCheck.php+++ b/app/Notifications/Server/ServerPatchCheck.php@@ -30,6 +30,21 @@ class ServerPatchCheck extends CustomEmailNotificationpublic function toMail($notifiable = null): MailMessage{$mail = new MailMessage;++ // Handle error case+ if (isset($this->patchData['error'])) {+ $mail->subject("Coolify: [ERROR] Failed to check patches on {$this->server->name}");+ $mail->view('emails.server-patches-error', [+ 'name' => $this->server->name,+ 'error' => $this->patchData['error'],+ 'osId' => $this->patchData['osId'] ?? 'unknown',+ 'package_manager' => $this->patchData['package_manager'] ?? 'unknown',+ 'server_url' => $this->serverUrl,+ ]);++ return $mail;+ }+$totalUpdates = $this->patchData['total_updates'] ?? 0;$mail->subject("Coolify: [ACTION REQUIRED] {$totalUpdates} server patches available on {$this->server->name}");$mail->view('emails.server-patches', [@@ -46,6 +61,26 @@ class ServerPatchCheck extends CustomEmailNotificationpublic function toDiscord(): DiscordMessage{+ // Handle error case+ if (isset($this->patchData['error'])) {+ $osId = $this->patchData['osId'] ?? 'unknown';+ $packageManager = $this->patchData['package_manager'] ?? 'unknown';+ $error = $this->patchData['error'];++ $description = "**Failed to check for updates** on server {$this->server->name}\n\n";+ $description .= "**Error Details:**\n";+ $description .= '• OS: '.ucfirst($osId)."\n";+ $description .= "• Package Manager: {$packageManager}\n";+ $description .= "• Error: {$error}\n\n";+ $description .= "[Manage Server]($this->serverUrl)";++ return new DiscordMessage(+ title: ':x: Coolify: [ERROR] Failed to check patches on '.$this->server->name,+ description: $description,+ color: DiscordMessage::errorColor(),+ );+ }+$totalUpdates = $this->patchData['total_updates'] ?? 0;$updates = $this->patchData['updates'] ?? [];$osId = $this->patchData['osId'] ?? 'unknown';@@ -92,6 +127,29 @@ class ServerPatchCheck extends CustomEmailNotificationpublic function toTelegram(): array{+ // Handle error case+ if (isset($this->patchData['error'])) {+ $osId = $this->patchData['osId'] ?? 'unknown';+ $packageManager = $this->patchData['package_manager'] ?? 'unknown';+ $error = $this->patchData['error'];++ $message = "❌ Coolify: [ERROR] Failed to check patches on {$this->server->name}!\n\n";+ $message .= "📊 Error Details:\n";+ $message .= '• OS: '.ucfirst($osId)."\n";+ $message .= "• Package Manager: {$packageManager}\n";+ $message .= "• Error: {$error}\n\n";++ return [+ 'message' => $message,+ 'buttons' => [+ [+ 'text' => 'Manage Server',+ 'url' => $this->serverUrl,+ ],+ ],+ ];+ }+$totalUpdates = $this->patchData['total_updates'] ?? 0;$updates = $this->patchData['updates'] ?? [];$osId = $this->patchData['osId'] ?? 'unknown';@@ -145,6 +203,31 @@ class ServerPatchCheck extends CustomEmailNotificationpublic function toPushover(): PushoverMessage{+ // Handle error case+ if (isset($this->patchData['error'])) {+ $osId = $this->patchData['osId'] ?? 'unknown';+ $packageManager = $this->patchData['package_manager'] ?? 'unknown';+ $error = $this->patchData['error'];++ $message = "[ERROR] Failed to check patches on {$this->server->name}!\n\n";+ $message .= "Error Details:\n";+ $message .= '• OS: '.ucfirst($osId)."\n";+ $message .= "• Package Manager: {$packageManager}\n";+ $message .= "• Error: {$error}\n\n";++ return new PushoverMessage(+ title: 'Server patch check failed',+ level: 'error',+ message: $message,+ buttons: [+ [+ 'text' => 'Manage Server',+ 'url' => $this->serverUrl,+ ],+ ],+ );+ }+$totalUpdates = $this->patchData['total_updates'] ?? 0;$updates = $this->patchData['updates'] ?? [];$osId = $this->patchData['osId'] ?? 'unknown';@@ -194,6 +277,26 @@ class ServerPatchCheck extends CustomEmailNotificationpublic function toSlack(): SlackMessage{+ // Handle error case+ if (isset($this->patchData['error'])) {+ $osId = $this->patchData['osId'] ?? 'unknown';+ $packageManager = $this->patchData['package_manager'] ?? 'unknown';+ $error = $this->patchData['error'];++ $description = "Failed to check patches on '{$this->server->name}'!\n\n";+ $description .= "*Error Details:*\n";+ $description .= '• OS: '.ucfirst($osId)."\n";+ $description .= "• Package Manager: {$packageManager}\n";+ $description .= "• Error: `{$error}`\n\n";+ $description .= "\n:link: <{$this->serverUrl}|Manage Server>";++ return new SlackMessage(+ title: 'Coolify: [ERROR] Server patch check failed',+ description: $description,+ color: SlackMessage::errorColor()+ );+ }+$totalUpdates = $this->patchData['total_updates'] ?? 0;$updates = $this->patchData['updates'] ?? [];$osId = $this->patchData['osId'] ?? 'unknown';diff --git a/resources/views/emails/server-patches-error.blade.php b/resources/views/emails/server-patches-error.blade.phpnew file mode 100644index 0000000000..070ead4402--- /dev/null+++ b/resources/views/emails/server-patches-error.blade.php@@ -0,0 +1,13 @@+<x-emails.layout>+Failed to check for package updates on your server {{ $name }}.++## Error Details++- Operating System: {{ ucfirst($osId) }}+- Package Manager: {{ $package_manager }}+- Error: {{ $error }}++---++You can manage your server and view more details in your [Coolify Dashboard]({{ $server_url }}).+</x-emails.layout>