From f1cefdcd440257f8f77a4a80c0d503875b350320 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Sat, 18 Jul 2026 11:21:50 +1200 Subject: [PATCH] (fix): reject empty project database DSN --- src/Appwrite/Platform/Modules/Databases/Pool.php | 6 +++++- tests/unit/Platform/Modules/Databases/PoolTest.php | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Modules/Databases/Pool.php b/src/Appwrite/Platform/Modules/Databases/Pool.php index b78304de86..960dbd13ff 100644 --- a/src/Appwrite/Platform/Modules/Databases/Pool.php +++ b/src/Appwrite/Platform/Modules/Databases/Pool.php @@ -33,7 +33,11 @@ final class Pool $sharedTables = \array_filter(\explode(',', System::getEnv('_APP_DATABASE_VECTORSDB_SHARED_TABLES', ''))); break; default: - return $projectDsn ?? ''; + if (empty($projectDsn)) { + throw new Exception(Exception::GENERAL_SERVER_ERROR, "Project database DSN is required for {$type} databases"); + } + + return $projectDsn; } $projectUsesSharedTables = false; diff --git a/tests/unit/Platform/Modules/Databases/PoolTest.php b/tests/unit/Platform/Modules/Databases/PoolTest.php index a2c2c7a1d6..0ae7e2ebb7 100644 --- a/tests/unit/Platform/Modules/Databases/PoolTest.php +++ b/tests/unit/Platform/Modules/Databases/PoolTest.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Tests\Unit\Platform\Modules\Databases; +use Appwrite\Extend\Exception; use Appwrite\Platform\Modules\Databases\Pool; use PHPUnit\Framework\TestCase; use Utopia\Config\Config; @@ -55,6 +56,14 @@ final class PoolTest extends TestCase $this->assertSame($dsn, Pool::dsn('tablesdb', 'default', $dsn)); } + public function testRejectsEmptyProjectDatabaseForTablesDB(): void + { + $this->expectException(Exception::class); + $this->expectExceptionMessage('Project database DSN is required for tablesdb databases'); + + Pool::dsn('tablesdb', 'default', null); + } + public function testSelectsDocumentsDatabasePool(): void { Config::setParam('pools-documentsdb', ['documents']);