diff --git a/.changes/wrong-docker-compose-file-not-found.md b/.changes/wrong-docker-compose-file-not-found.md
new file mode 100644
index 0000000000..2a421e9c31
--- /dev/null
+++ b/.changes/wrong-docker-compose-file-not-found.md
@@ -0,0 +1,6 @@
+---
+type: fixed
+---
+Wrong `Docker Compose file not found` error for an empty Compose file ([#12477](https://github.com/coollabsio/coolify/issues/12477))
+
+- An empty Compose file now gives an error that says that the file is empty
diff --git a/app/Models/Application.php b/app/Models/Application.php
index 2699cbaf79..d2a498e730 100644
--- a/app/Models/Application.php
+++ b/app/Models/Application.php
@@ -2823,7 +2823,7 @@ class Application extends BaseModel
$this->base_directory = $initialBaseDirectory;
$this->save();
- throw new RuntimeException("Docker Compose file not found at: $workdir$composeFile (branch: {$this->git_branch})
Check if you used the right extension (.yaml or .yml) in the compose file name.");
+ throw new RuntimeException("Docker Compose file at $workdir$composeFile (branch: {$this->git_branch}) is empty.
Check that the file in the repository has content and that your changes are committed and pushed.");
}
}
diff --git a/tests/Feature/ComposeFileLoadErrorTest.php b/tests/Feature/ComposeFileLoadErrorTest.php
index c266f5c795..ba161306b7 100644
--- a/tests/Feature/ComposeFileLoadErrorTest.php
+++ b/tests/Feature/ComposeFileLoadErrorTest.php
@@ -86,3 +86,21 @@ it('tells the user that a symlinked Compose file is not loaded', function () {
->toThrow(RuntimeException::class, 'Docker Compose file at /docker-compose.yml (branch: main) is a symbolic link.');
expect($this->application->fresh()->docker_compose_raw)->toBe("services:\n web:\n image: nginx\n");
});
+
+it('tells the user that the Compose file is empty, not that it is missing', function () {
+ fakeComposeLoadServer(null, '');
+
+ expect(fn () => $this->application->loadComposeFile())
+ ->toThrow(function (RuntimeException $exception) {
+ expect($exception->getMessage())
+ ->toContain('Docker Compose file at /docker-compose.yml (branch: main) is empty.')
+ ->not->toContain('not found');
+ });
+});
+
+it('tells the user that the Compose file is missing', function () {
+ fakeComposeLoadServer('git ls-tree', 'No such file');
+
+ expect(fn () => $this->application->loadComposeFile())
+ ->toThrow(RuntimeException::class, 'Docker Compose file not found at: /docker-compose.yml (branch: main)');
+});