From 7d754558b0b5b6312404e13b6587698fd0550982 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 24 Jan 2024 12:26:14 +0100 Subject: [PATCH] Fix branch selection and handle missing service --- app/Livewire/Project/New/GithubPrivateRepository.php | 2 +- app/Livewire/Project/Service/Configuration.php | 5 ++++- app/Models/Application.php | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/Livewire/Project/New/GithubPrivateRepository.php b/app/Livewire/Project/New/GithubPrivateRepository.php index 4108727f3..9ae9aeb57 100644 --- a/app/Livewire/Project/New/GithubPrivateRepository.php +++ b/app/Livewire/Project/New/GithubPrivateRepository.php @@ -95,7 +95,7 @@ class GithubPrivateRepository extends Component $this->loadBranchByPage(); } } - $this->selected_branch_name = data_get($this->branches,'0.name'); + $this->selected_branch_name = data_get($this->branches, '0.name', 'main'); } protected function loadBranchByPage() diff --git a/app/Livewire/Project/Service/Configuration.php b/app/Livewire/Project/Service/Configuration.php index 5954b3b36..32c174520 100644 --- a/app/Livewire/Project/Service/Configuration.php +++ b/app/Livewire/Project/Service/Configuration.php @@ -30,7 +30,10 @@ class Configuration extends Component { $this->parameters = get_route_parameters(); $this->query = request()->query(); - $this->service = Service::whereUuid($this->parameters['service_uuid'])->firstOrFail(); + $this->service = Service::whereUuid($this->parameters['service_uuid'])->first(); + if (!$this->service) { + return redirect()->route('dashboard'); + } $this->applications = $this->service->applications->sort(); $this->databases = $this->service->databases->sort(); } diff --git a/app/Models/Application.php b/app/Models/Application.php index 79f888797..116cfdd76 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -1006,7 +1006,7 @@ class Application extends BaseModel if (!$composeFileContent) { $this->docker_compose_location = $initialDockerComposeLocation; $this->save(); - throw new \Exception("Could not load base compose file from $workdir$composeFile"); + throw new \RuntimeException("Could not load base compose file from $workdir$composeFile"); } else { $this->docker_compose_raw = $composeFileContent; $this->save();