From 372b064dba8c5fecfffb3f6795136b72503cec5c Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 18 Feb 2025 16:44:05 +0100 Subject: [PATCH] fix(core): improve server selection error handling in Docker component --- app/Livewire/Destination/New/Docker.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/Livewire/Destination/New/Docker.php b/app/Livewire/Destination/New/Docker.php index 0e60025e5..eb768d191 100644 --- a/app/Livewire/Destination/New/Docker.php +++ b/app/Livewire/Destination/New/Docker.php @@ -35,10 +35,18 @@ class Docker extends Component $this->network = new Cuid2; $this->servers = Server::isUsable()->get(); if ($server_id) { - $this->selectedServer = $this->servers->find($server_id) ?: $this->servers->first(); + $foundServer = $this->servers->find($server_id) ?: $this->servers->first(); + if (! $foundServer) { + throw new \Exception('Server not found.'); + } + $this->selectedServer = $foundServer; $this->serverId = $this->selectedServer->id; } else { - $this->selectedServer = $this->servers->first(); + $foundServer = $this->servers->first(); + if (! $foundServer) { + throw new \Exception('Server not found.'); + } + $this->selectedServer = $foundServer; $this->serverId = $this->selectedServer->id; } $this->generateName();