Skip to content

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.

fix(core): improve server selection error handling in Docker component

Andras Bacsai372b064dba8c
diff --git a/app/Livewire/Destination/New/Docker.php b/app/Livewire/Destination/New/Docker.php
index 0e60025e56..eb768d1916 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();