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
Merge remote-tracking branch 'origin/next' into 2731-investigate-failed-git-clone
Andras Bacsai7542c71dc45f
diff --cc app/Http/Controllers/Api/ApplicationsController.phpindex 4b0cfc6ab8,77f4e626f9..a4817fcda4--- a/app/Http/Controllers/Api/ApplicationsController.php+++ b/app/Http/Controllers/Api/ApplicationsController.php@@@ -1051,6 -1058,7 +1058,7 @@@ class ApplicationsController extends Co$connectToDockerNetwork = $request->connect_to_docker_network;$customNginxConfiguration = $request->custom_nginx_configuration;$isContainerLabelEscapeEnabled = $request->boolean('is_container_label_escape_enabled', true);- $isPreserveRepositoryEnabled = $request->boolean('is_preserve_repository_enabled',false);++ $isPreserveRepositoryEnabled = $request->boolean('is_preserve_repository_enabled', false);if (! is_null($customNginxConfiguration)) {if (! isBase64Encoded($customNginxConfiguration)) {diff --cc app/Models/Application.phpindex e622c9d541,fef6f6e4c3..16f25dfcf3--- a/app/Models/Application.php+++ b/app/Models/Application.php@@@ -1087,13 -1187,15 +1187,18 @@@ class Application extends BaseModereturn application_configuration_dir()."/{$this->uuid}";}- public function setGitImportSettings(string $deployment_uuid, string $git_clone_command, bool $public = false, ?string $commit = null, ?string $gitSshCommand = null)- public function setGitImportSettings(string $deployment_uuid, string $git_clone_command, bool $public = false, ?string $commit = null, ?string $git_ssh_command = null)++ public function setGitImportSettings(string $deployment_uuid, string $git_clone_command, bool $public = false, ?string $commit = null, ?string $gitSshCommand = null, ?string $git_ssh_command = null){$baseDir = $this->generateBaseDir($deployment_uuid);$escapedBaseDir = escapeshellarg($baseDir);$isShallowCloneEnabled = $this->settings?->is_git_shallow_clone_enabled ?? false;- $sshCommand = $gitSshCommand ?? 'ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null';- // Use the full GIT_SSH_COMMAND (including -i for SSH key and port options) when provided,- // so that git fetch, submodule update, and lfs pull can authenticate the same way as git clone.- $sshCommand = $git_ssh_command ?? 'GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"';++ $resolvedGitSshCommand = $git_ssh_command ?? $gitSshCommand;++ $sshCommand = $resolvedGitSshCommand++ ? (str_starts_with($resolvedGitSshCommand, 'GIT_SSH_COMMAND=')++ ? $resolvedGitSshCommand++ : 'GIT_SSH_COMMAND="'.$resolvedGitSshCommand.'"')++ : 'GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"';// Use the explicitly passed commit (e.g. from rollback), falling back to the application's git_commit_sha.// Invalid refs will cause the git checkout/fetch command to fail on the remote server.@@@ -1303,19 -1462,14 +1465,22 @@@}} else {$github_access_token = generateGithubInstallationToken($this->source);- // Configure git to rewrite URLs with the token so submodules on the same host authenticate correctly- $escapedTokenUrl = escapeshellarg("{$source_html_url_scheme}://x-access-token:{$github_access_token}@{$source_html_url_host}/");+ $encodedToken = rawurlencode($github_access_token);++++ // Configure git to rewrite URLs with the token so submodules on the same host authenticate correctly.++ $escapedTokenUrl = escapeshellarg("{$source_html_url_scheme}://x-access-token:{$encodedToken}@{$source_html_url_host}/");+ $escapedHostUrl = escapeshellarg("{$source_html_url_scheme}://{$source_html_url_host}/");+ $gitConfigCommand = "git config --global url.{$escapedTokenUrl}.insteadOf {$escapedHostUrl}";++if ($exec_in_docker) {+ $commands->push(executeInDocker($deployment_uuid, $gitConfigCommand));- $repoUrl = "$source_html_url_scheme://x-access-token:$github_access_token@$source_html_url_host/{$customRepository}.git";+ $repoUrl = "$source_html_url_scheme://x-access-token:$encodedToken@$source_html_url_host/{$customRepository}.git";$escapedRepoUrl = escapeshellarg($repoUrl);$git_clone_command = "{$git_clone_command} {$escapedRepoUrl} {$escapedBaseDir}";$fullRepoUrl = $repoUrl;} else {+ $commands->push($gitConfigCommand);- $repoUrl = "$source_html_url_scheme://x-access-token:$github_access_token@$source_html_url_host/{$customRepository}";+ $repoUrl = "$source_html_url_scheme://x-access-token:$encodedToken@$source_html_url_host/{$customRepository}";$escapedRepoUrl = escapeshellarg($repoUrl);$git_clone_command = "{$git_clone_command} {$escapedRepoUrl} {$escapedBaseDir}";$fullRepoUrl = $repoUrl;@@@ -1356,8 -1582,8 +1593,9 @@@}$private_key = base64_encode($private_key);$escapedCustomRepository = escapeshellarg($customRepository);- $deployKeySshCommand = "GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$customPort} -o Port={$customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\"";- $git_clone_command_base = "{$deployKeySshCommand} {$git_clone_command} {$escapedCustomRepository} {$escapedBaseDir}";+ $deployKeySshCommand = "ssh -o ConnectTimeout=30 -p {$customPort} -o Port={$customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa";- $git_clone_command_base = "GIT_SSH_COMMAND=\"{$deployKeySshCommand}\" {$git_clone_command} {$escapedCustomRepository} {$escapedBaseDir}";++ $deployKeyGitSshCommand = "GIT_SSH_COMMAND=\"{$deployKeySshCommand}\"";++ $git_clone_command_base = "{$deployKeyGitSshCommand} {$git_clone_command} {$escapedCustomRepository} {$escapedBaseDir}";if ($only_checkout) {$git_clone_command = $git_clone_command_base;} else {diff --cc bootstrap/helpers/api.phpindex 1b03a4d374,c10ed6158d..05a46dc981--- a/bootstrap/helpers/api.php+++ b/bootstrap/helpers/api.php@@@ -134,13 -136,15 +136,15 @@@ function sharedDataApplications('manual_webhook_secret_gitlab' => 'string|nullable','manual_webhook_secret_bitbucket' => 'string|nullable','manual_webhook_secret_gitea' => 'string|nullable',- 'dockerfile_location' => ['string', 'nullable', 'max:255', 'regex:/^\/[a-zA-Z0-9._\-\/]+$/'],- 'docker_compose_location' => ['string', 'nullable', 'max:255', 'regex:/^\/[a-zA-Z0-9._\-\/]+$/'],+ 'dockerfile_location' => \App\Support\ValidationPatterns::filePathRules(),+ 'dockerfile_target_build' => \App\Support\ValidationPatterns::dockerTargetRules(),+ 'docker_compose_location' => \App\Support\ValidationPatterns::filePathRules(),'docker_compose' => 'string|nullable','docker_compose_domains' => 'array|nullable',- 'docker_compose_custom_start_command' => 'string|nullable',- 'docker_compose_custom_build_command' => 'string|nullable',+ 'docker_compose_custom_start_command' => \App\Support\ValidationPatterns::shellSafeCommandRules(),+ 'docker_compose_custom_build_command' => \App\Support\ValidationPatterns::shellSafeCommandRules(),'is_container_label_escape_enabled' => 'boolean',- 'is_preserve_repository_enabled' => 'boolean'++ 'is_preserve_repository_enabled' => 'boolean',];}diff --cc bootstrap/helpers/proxy.phpindex ac52c0af8c,ed18dfe760..d443c84a4b--- a/bootstrap/helpers/proxy.php+++ b/bootstrap/helpers/proxy.php@@@ -108,18 -109,20 +109,22 @@@ function connectProxyToNetworks(Server['networks' => $networks] = collectDockerNetworksByServer($server);if ($server->isSwarm()) {$commands = $networks->map(function ($network) {+ $safe = escapeshellarg($network);++return [- "docker network ls --format '{{.Name}}' | grep '^$network$' >/dev/null || docker network create --driver overlay --attachable $network >/dev/null",- "docker network connect $network coolify-proxy >/dev/null 2>&1 || true",- "echo 'Successfully connected coolify-proxy to $network network.'",+ "docker network ls --format '{{.Name}}' | grep '^{$network}$' >/dev/null || docker network create --driver overlay --attachable {$safe} >/dev/null",+ "docker network connect {$safe} coolify-proxy >/dev/null 2>&1 || true",+ "echo 'Successfully connected coolify-proxy to {$safe} network.'",];});} else {$commands = $networks->map(function ($network) {+ $safe = escapeshellarg($network);++return [- "docker network ls --format '{{.Name}}' | grep '^$network$' >/dev/null || docker network create --attachable $network >/dev/null",- "docker network connect $network coolify-proxy >/dev/null 2>&1 || true",- "echo 'Successfully connected coolify-proxy to $network network.'",+ "docker network ls --format '{{.Name}}' | grep '^{$network}$' >/dev/null || docker network create --attachable {$safe} >/dev/null",+ "docker network connect {$safe} coolify-proxy >/dev/null 2>&1 || true",+ "echo 'Successfully connected coolify-proxy to {$safe} network.'",];});}@@@ -140,16 -143,18 +145,20 @@@ function ensureProxyNetworksExist(Serveif ($server->isSwarm()) {$commands = $networks->map(function ($network) {+ $safe = escapeshellarg($network);++return [- "echo 'Ensuring network $network exists...'",- "docker network ls --format '{{.Name}}' | grep -q '^{$network}$' || docker network create --driver overlay --attachable $network",+ "echo 'Ensuring network {$safe} exists...'",+ "docker network ls --format '{{.Name}}' | grep -q '^{$network}$' || docker network create --driver overlay --attachable {$safe}",];});} else {$commands = $networks->map(function ($network) {+ $safe = escapeshellarg($network);++return [- "echo 'Ensuring network $network exists...'",- "docker network ls --format '{{.Name}}' | grep -q '^{$network}$' || docker network create --attachable $network",+ "echo 'Ensuring network {$safe} exists...'",+ "docker network ls --format '{{.Name}}' | grep -q '^{$network}$' || docker network create --attachable {$safe}",];});}diff --cc routes/web.phpindex 26863aa175,6d70b42239..116480bb4a--- a/routes/web.php+++ b/routes/web.php@@@ -33,7 -33,7 +33,6 @@@ use App\Livewire\Project\Service\Databause App\Livewire\Project\Service\Index as ServiceIndex;use App\Livewire\Project\Shared\ExecuteContainerCommand;use App\Livewire\Project\Shared\Logs;--use App\Livewire\Project\Shared\ScheduledTask\Show as ScheduledTaskShow;use App\Livewire\Project\Show as ProjectShow;use App\Livewire\Security\ApiTokens;use App\Livewire\Security\CloudInitScripts;diff --cc tests/Feature/CrossTeamIdorServerProjectTest.phpindex 0000000000,671397a1ed..95328c63f5mode 000000,100644..100644--- a/tests/Feature/CrossTeamIdorServerProjectTest.php+++ b/tests/Feature/CrossTeamIdorServerProjectTest.php@@@ -1,0 -1,182 +1,182 @@@+ <?php++ use App\Livewire\Boarding\Index as BoardingIndex;+ use App\Livewire\GlobalSearch;+ use App\Livewire\Project\CloneMe;+ use App\Livewire\Project\DeleteProject;+ use App\Models\Environment;+ use App\Models\Project;+ use App\Models\Server;+ use App\Models\StandaloneDocker;+ use App\Models\Team;+ use App\Models\User;+ use Illuminate\Foundation\Testing\RefreshDatabase;+ use Livewire\Livewire;++ uses(RefreshDatabase::class);++ beforeEach(function () {+ // Attacker: Team A+ $this->userA = User::factory()->create();+ $this->teamA = Team::factory()->create();+ $this->userA->teams()->attach($this->teamA, ['role' => 'owner']);++ $this->serverA = Server::factory()->create(['team_id' => $this->teamA->id]);+ $this->projectA = Project::factory()->create(['team_id' => $this->teamA->id]);+ $this->environmentA = Environment::factory()->create(['project_id' => $this->projectA->id]);++ // Victim: Team B+ $this->userB = User::factory()->create();+ $this->teamB = Team::factory()->create();+ $this->userB->teams()->attach($this->teamB, ['role' => 'owner']);++ $this->serverB = Server::factory()->create(['team_id' => $this->teamB->id]);+ $this->projectB = Project::factory()->create(['team_id' => $this->teamB->id]);+ $this->environmentB = Environment::factory()->create(['project_id' => $this->projectB->id]);++ // Act as attacker (Team A)+ $this->actingAs($this->userA);+ session(['currentTeam' => $this->teamA]);+ });++ describe('Boarding Server IDOR (GHSA-qfcc-2fm3-9q42)', function () {+ test('boarding mount cannot load server from another team via selectedExistingServer', function () {+ $component = Livewire::test(BoardingIndex::class, [+ 'selectedServerType' => 'remote',+ 'selectedExistingServer' => $this->serverB->id,+ ]);++ // The server from Team B should NOT be loaded+ expect($component->get('createdServer'))->toBeNull();+ });++ test('boarding mount can load own team server via selectedExistingServer', function () {+ $component = Livewire::test(BoardingIndex::class, [+ 'selectedServerType' => 'remote',+ 'selectedExistingServer' => $this->serverA->id,+ ]);++ // Own team server should load successfully+ expect($component->get('createdServer'))->not->toBeNull();+ expect($component->get('createdServer')->id)->toBe($this->serverA->id);+ });+ });++ describe('Boarding Project IDOR (GHSA-qfcc-2fm3-9q42)', function () {+ test('boarding mount cannot load project from another team via selectedProject', function () {+ $component = Livewire::test(BoardingIndex::class, [+ 'selectedProject' => $this->projectB->id,+ ]);++ // The project from Team B should NOT be loaded+ expect($component->get('createdProject'))->toBeNull();+ });++ test('boarding selectExistingProject cannot load project from another team', function () {+ $component = Livewire::test(BoardingIndex::class)+ ->set('selectedProject', $this->projectB->id)+ ->call('selectExistingProject');++ expect($component->get('createdProject'))->toBeNull();+ $component->assertDispatched('error');+ });++ test('boarding selectExistingProject can load own team project', function () {+ $component = Livewire::test(BoardingIndex::class)+ ->set('selectedProject', $this->projectA->id)+ ->call('selectExistingProject');++ expect($component->get('createdProject'))->not->toBeNull();+ expect($component->get('createdProject')->id)->toBe($this->projectA->id);+ });+ });++ describe('GlobalSearch Server IDOR (GHSA-qfcc-2fm3-9q42)', function () {+ test('loadDestinations cannot access server from another team', function () {+ $component = Livewire::test(GlobalSearch::class)+ ->set('selectedServerId', $this->serverB->id)+ ->call('loadDestinations');++ // Should dispatch error because server is not found (team-scoped)+ $component->assertDispatched('error');+ });+ });++ describe('GlobalSearch Project IDOR (GHSA-qfcc-2fm3-9q42)', function () {+ test('loadEnvironments cannot access project from another team', function () {+ $component = Livewire::test(GlobalSearch::class)+ ->set('selectedProjectUuid', $this->projectB->uuid)+ ->call('loadEnvironments');++ // Should not load environments from another team's project+ expect($component->get('availableEnvironments'))->toBeEmpty();+ });+ });++ describe('DeleteProject IDOR (GHSA-qfcc-2fm3-9q42)', function () {+ test('cannot mount DeleteProject with project from another team', function () {+ // Should throw ModelNotFoundException (404) because team-scoped query won't find it+ Livewire::test(DeleteProject::class, ['project_id' => $this->projectB->id]);+ })->throws(\Illuminate\Database\Eloquent\ModelNotFoundException::class);++ test('can mount DeleteProject with own team project', function () {+ $component = Livewire::test(DeleteProject::class, ['project_id' => $this->projectA->id]);++ expect($component->get('projectName'))->toBe($this->projectA->name);+ });+ });++ describe('CloneMe Project IDOR (GHSA-qfcc-2fm3-9q42)', function () {+ test('cannot mount CloneMe with project UUID from another team', function () {+ // Should throw ModelNotFoundException because team-scoped query won't find it+ Livewire::test(CloneMe::class, [+ 'project_uuid' => $this->projectB->uuid,+ 'environment_uuid' => $this->environmentB->uuid,+ ]);+ })->throws(\Illuminate\Database\Eloquent\ModelNotFoundException::class);++ test('can mount CloneMe with own team project UUID', function () {+ $component = Livewire::test(CloneMe::class, [+ 'project_uuid' => $this->projectA->uuid,+ 'environment_uuid' => $this->environmentA->uuid,+ ]);++ expect($component->get('project_id'))->toBe($this->projectA->id);+ });+ });++ describe('DeployController API Server IDOR (GHSA-qfcc-2fm3-9q42)', function () {+ test('deploy cancel API cannot access build server from another team', function () {+ // Create a deployment queue entry that references Team B's server as build_server+ $application = \App\Models\Application::factory()->create([+ 'environment_id' => $this->environmentA->id,+ 'destination_id' => StandaloneDocker::factory()->create(['server_id' => $this->serverA->id])->id,+ 'destination_type' => StandaloneDocker::class,+ ]);++ $deployment = \App\Models\ApplicationDeploymentQueue::create([+ 'application_id' => $application->id,- 'deployment_uuid' => 'test-deploy-' . fake()->uuid(),++ 'deployment_uuid' => 'test-deploy-'.fake()->uuid(),+ 'server_id' => $this->serverA->id,+ 'build_server_id' => $this->serverB->id, // Cross-team build server+ 'status' => \App\Enums\ApplicationDeploymentStatus::IN_PROGRESS->value,+ ]);++ $token = $this->userA->createToken('test-token', ['*']);++ $response = $this->withHeaders([- 'Authorization' => 'Bearer ' . $token->plainTextToken,++ 'Authorization' => 'Bearer '.$token->plainTextToken,+ ])->deleteJson("/api/v1/deployments/{$deployment->deployment_uuid}");++ // The cancellation should proceed but the build_server should NOT be found+ // (team-scoped query returns null for Team B's server)+ // The deployment gets cancelled but no remote process runs on the wrong server+ $response->assertOk();++ // Verify the deployment was cancelled+ $deployment->refresh();+ expect($deployment->status)->toBe(+ \App\Enums\ApplicationDeploymentStatus::CANCELLED_BY_USER->value+ );+ });+ });diff --cc tests/Unit/ProxyConfigRecoveryTest.phpindex 0000000000,e10d899fee..682407bdfemode 000000,100644..100644--- a/tests/Unit/ProxyConfigRecoveryTest.php+++ b/tests/Unit/ProxyConfigRecoveryTest.php@@@ -1,0 -1,173 +1,173 @@@+ <?php++ use App\Actions\Proxy\GetProxyConfiguration;+ use Illuminate\Support\Facades\Cache;+ use Illuminate\Support\Facades\Log;+ use Spatie\SchemalessAttributes\SchemalessAttributes;++ beforeEach(function () {+ Log::spy();+ Cache::spy();+ });++ function mockServerWithDbConfig(?string $savedConfig, string $proxyType = 'TRAEFIK'): object+ {+ $proxyAttributes = Mockery::mock(SchemalessAttributes::class);+ $proxyAttributes->shouldReceive('get')+ ->with('last_saved_proxy_configuration')+ ->andReturn($savedConfig);++ $proxyPath = match ($proxyType) {+ 'CADDY' => '/data/coolify/proxy/caddy',+ 'NGINX' => '/data/coolify/proxy/nginx',+ default => '/data/coolify/proxy/',+ };++ $server = Mockery::mock('App\Models\Server');+ $server->shouldIgnoreMissing();+ $server->shouldReceive('getAttribute')->with('proxy')->andReturn($proxyAttributes);+ $server->shouldReceive('getAttribute')->with('id')->andReturn(1);+ $server->shouldReceive('getAttribute')->with('name')->andReturn('Test Server');+ $server->shouldReceive('proxyType')->andReturn($proxyType);+ $server->shouldReceive('proxyPath')->andReturn($proxyPath);++ return $server;+ }++ it('returns OK for NONE proxy type without reading config', function () {+ $server = Mockery::mock('App\Models\Server');+ $server->shouldIgnoreMissing();+ $server->shouldReceive('proxyType')->andReturn('NONE');++ $result = GetProxyConfiguration::run($server);++ expect($result)->toBe('OK');+ });++ it('reads proxy configuration from database', function () {+ $savedConfig = "services:\n traefik:\n image: traefik:v3.5\n";+ $server = mockServerWithDbConfig($savedConfig);++ // ProxyDashboardCacheService is called at the end — mock it+ $server->shouldReceive('proxyType')->andReturn('TRAEFIK');++ $result = GetProxyConfiguration::run($server);++ expect($result)->toBe($savedConfig);+ });++ it('preserves full custom config including labels, env vars, and custom commands', function () {+ $customConfig = <<<'YAML'+ services:+ traefik:+ image: traefik:v3.5+ command:+ - '--entrypoints.http.address=:80'+ - '--metrics.prometheus=true'+ labels:+ - 'traefik.enable=true'+ - 'waf.custom.middleware=true'+ environment:+ CF_API_EMAIL: [email protected]+ CF_API_KEY: secret-key+ YAML;++ $server = mockServerWithDbConfig($customConfig);++ $result = GetProxyConfiguration::run($server);++ expect($result)->toBe($customConfig)+ ->and($result)->toContain('waf.custom.middleware=true')+ ->and($result)->toContain('CF_API_EMAIL')+ ->and($result)->toContain('metrics.prometheus=true');+ });++ it('logs warning when regenerating defaults', function () {+ Log::swap(new \Illuminate\Log\LogManager(app()));+ Log::spy();++ // No DB config, no disk config — will try to regenerate+ $server = mockServerWithDbConfig(null);++ // backfillFromDisk will be called — we need instant_remote_process to return empty+ // Since it's a global function we can't easily mock it, so test the logging via+ // the force regenerate path instead+ try {+ GetProxyConfiguration::run($server, forceRegenerate: true);+ } catch (\Throwable $e) {+ // generateDefaultProxyConfiguration may fail without full server setup+ }++ Log::shouldHaveReceived('warning')+ ->withArgs(fn ($message) => str_contains($message, 'regenerated to defaults'))+ ->once();+ });++ it('does not read from disk when DB config exists', function () {+ $savedConfig = "services:\n traefik:\n image: traefik:v3.5\n";+ $server = mockServerWithDbConfig($savedConfig);++ // If disk were read, instant_remote_process would be called.+ // Since we're not mocking it and the test passes, it proves DB is used.+ $result = GetProxyConfiguration::run($server);++ expect($result)->toBe($savedConfig);+ });++ it('rejects stored Traefik config when proxy type is CADDY', function () {+ Log::swap(new \Illuminate\Log\LogManager(app()));+ Log::spy();++ $traefikConfig = "services:\n traefik:\n image: traefik:v3.6\n";+ $server = mockServerWithDbConfig($traefikConfig, 'CADDY');++ // Config type mismatch should trigger regeneration, which will try+ // backfillFromDisk (instant_remote_process) then generateDefault.+ // Both will fail in test env, but the warning log proves mismatch was detected.+ try {+ GetProxyConfiguration::run($server);+ } catch (\Throwable $e) {+ // Expected — regeneration requires SSH/full server setup+ }++ Log::shouldHaveReceived('warning')+ ->withArgs(fn ($message) => str_contains($message, 'does not match current proxy type'))+ ->once();+ });++ it('rejects stored Caddy config when proxy type is TRAEFIK', function () {+ Log::swap(new \Illuminate\Log\LogManager(app()));+ Log::spy();++ $caddyConfig = "services:\n caddy:\n image: lucaslorentz/caddy-docker-proxy:2.8-alpine\n";+ $server = mockServerWithDbConfig($caddyConfig, 'TRAEFIK');++ try {+ GetProxyConfiguration::run($server);+ } catch (\Throwable $e) {+ // Expected — regeneration requires SSH/full server setup+ }++ Log::shouldHaveReceived('warning')+ ->withArgs(fn ($message) => str_contains($message, 'does not match current proxy type'))+ ->once();+ });++ it('accepts stored Caddy config when proxy type is CADDY', function () {+ $caddyConfig = "services:\n caddy:\n image: lucaslorentz/caddy-docker-proxy:2.8-alpine\n";+ $server = mockServerWithDbConfig($caddyConfig, 'CADDY');++ $result = GetProxyConfiguration::run($server);++ expect($result)->toBe($caddyConfig);+ });++ it('accepts stored config when YAML parsing fails', function () {- $invalidYaml = "this: is: not: [valid yaml: {{{}}}";++ $invalidYaml = 'this: is: not: [valid yaml: {{{}}}';+ $server = mockServerWithDbConfig($invalidYaml, 'TRAEFIK');++ // Invalid YAML should not block — configMatchesProxyType returns true on parse failure+ $result = GetProxyConfiguration::run($server);++ expect($result)->toBe($invalidYaml);+ });