From 43eb0d10929b3560754192ac88c1b969c32f0137 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Fri, 10 Jul 2026 16:49:11 +0530 Subject: [PATCH 1/5] fix: filter Sites build runtimes by _APP_SITES_RUNTIMES listFrameworks was returning every framework runtime, so the Console showed uninstalled options unlike Functions. Filter against the env allowlist and reject unsupported buildRuntime on create/update. Co-authored-by: Cursor --- .../Platform/Modules/Sites/Http/Frameworks/XList.php | 9 +++++++++ .../Platform/Modules/Sites/Http/Sites/Create.php | 6 ++++++ .../Platform/Modules/Sites/Http/Sites/Update.php | 6 ++++++ 3 files changed, 21 insertions(+) diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Frameworks/XList.php b/src/Appwrite/Platform/Modules/Sites/Http/Frameworks/XList.php index b1f0a5bc1f..bd51f8ba70 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Frameworks/XList.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Frameworks/XList.php @@ -11,6 +11,7 @@ use Utopia\Config\Config; use Utopia\Database\Document; use Utopia\Platform\Action; use Utopia\Platform\Scope\HTTP; +use Utopia\System\System; class XList extends Base { @@ -52,11 +53,19 @@ class XList extends Base public function action(Response $response) { $frameworks = Config::getParam('frameworks'); + $allowList = \array_filter(\array_map('trim', \explode(',', System::getEnv('_APP_SITES_RUNTIMES', '')))); foreach ($frameworks as $key => $framework) { if (!empty($framework['adapters'])) { $frameworks[$key]['adapters'] = \array_values($framework['adapters']); } + + if (!empty($allowList) && !empty($framework['runtimes'])) { + $frameworks[$key]['runtimes'] = \array_values(\array_filter( + $framework['runtimes'], + fn ($runtime) => \in_array($runtime, $allowList, true) + )); + } } $response->dynamic(new Document([ diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Create.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Create.php index 3c51c57420..9472a82174 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Create.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Create.php @@ -144,6 +144,12 @@ class Create extends Base } } + $allowList = \array_filter(\array_map('trim', \explode(',', System::getEnv('_APP_SITES_RUNTIMES', '')))); + + if (!empty($allowList) && !\in_array($buildRuntime, $allowList, true)) { + throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Runtime "' . $buildRuntime . '" is not supported'); + } + $siteId = ($siteId == 'unique()') ? ID::unique() : $siteId; $installation = $dbForPlatform->getDocument('installations', $installationId); diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php index 532c92a428..b97f30ff58 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php @@ -158,6 +158,12 @@ class Update extends Base } } + $allowList = \array_filter(\array_map('trim', \explode(',', System::getEnv('_APP_SITES_RUNTIMES', '')))); + + if (!empty($allowList) && !empty($buildRuntime) && !\in_array($buildRuntime, $allowList, true)) { + throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Runtime "' . $buildRuntime . '" is not supported'); + } + // TODO: If only branch changes, re-deploy $site = $dbForProject->getDocument('sites', $siteId); From d0d1ab03380bf0b2ccbadefbae845de1a72376f8 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Fri, 10 Jul 2026 16:54:46 +0530 Subject: [PATCH 2/5] fix: omit frameworks with no enabled build runtimes After filtering by _APP_SITES_RUNTIMES, drop frameworks whose runtime list is empty so the Console does not offer unusable options. Co-authored-by: Cursor --- .../Platform/Modules/Sites/Http/Frameworks/XList.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Frameworks/XList.php b/src/Appwrite/Platform/Modules/Sites/Http/Frameworks/XList.php index bd51f8ba70..1be5199494 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Frameworks/XList.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Frameworks/XList.php @@ -65,6 +65,11 @@ class XList extends Base $framework['runtimes'], fn ($runtime) => \in_array($runtime, $allowList, true) )); + + // Drop frameworks that have no enabled build runtimes left. + if (empty($frameworks[$key]['runtimes'])) { + unset($frameworks[$key]); + } } } From a75d95a9b537c716cc0b0c9e37d4adcf6cd3944c Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Fri, 10 Jul 2026 17:28:49 +0530 Subject: [PATCH 3/5] fix: realign framework buildRuntime after allowlist filtering If the default buildRuntime is excluded by _APP_SITES_RUNTIMES, point it at the first remaining enabled runtime so clients do not preselect an invalid value. Co-authored-by: Cursor --- .../Platform/Modules/Sites/Http/Frameworks/XList.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Frameworks/XList.php b/src/Appwrite/Platform/Modules/Sites/Http/Frameworks/XList.php index 1be5199494..e49ace4486 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Frameworks/XList.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Frameworks/XList.php @@ -69,6 +69,12 @@ class XList extends Base // Drop frameworks that have no enabled build runtimes left. if (empty($frameworks[$key]['runtimes'])) { unset($frameworks[$key]); + continue; + } + + // Keep the default buildRuntime aligned with the filtered allowlist. + if (!\in_array($frameworks[$key]['buildRuntime'] ?? '', $frameworks[$key]['runtimes'], true)) { + $frameworks[$key]['buildRuntime'] = $frameworks[$key]['runtimes'][0]; } } } From b0a156893ec5da0ab25315955486db4d254d1684 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Fri, 10 Jul 2026 17:47:12 +0530 Subject: [PATCH 4/5] test: assert sites reject buildRuntime outside allowlist Co-authored-by: Cursor --- .../e2e/Services/Sites/SitesCustomServerTest.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index 0440d7afb7..d028beb79c 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -135,6 +135,21 @@ final class SitesCustomServerTest extends Scope $this->assertEquals(201, $variable2['headers']['status-code']); $this->assertEquals(201, $variable3['headers']['status-code']); + /** + * Test for FAILURE + * Reject buildRuntime values outside _APP_SITES_RUNTIMES (static-1,node-22 in test env). + */ + $site = $this->createSite([ + 'buildRuntime' => 'node-24', + 'framework' => 'other', + 'name' => 'Unsupported Runtime Site', + 'siteId' => ID::unique(), + ]); + + $this->assertEquals(400, $site['headers']['status-code']); + $this->assertEquals('general_argument_invalid', $site['body']['type']); + $this->assertStringContainsString('Runtime "node-24" is not supported', $site['body']['message']); + $this->cleanupSite($siteId); } From 030c653b3238bfb0a5eba176d5ab36900330e785 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Fri, 10 Jul 2026 17:51:30 +0530 Subject: [PATCH 5/5] test: cast sites allowlist assertion message for Rector Co-authored-by: Cursor --- tests/e2e/Services/Sites/SitesCustomServerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index d028beb79c..88e50ec7b4 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -148,7 +148,7 @@ final class SitesCustomServerTest extends Scope $this->assertEquals(400, $site['headers']['status-code']); $this->assertEquals('general_argument_invalid', $site['body']['type']); - $this->assertStringContainsString('Runtime "node-24" is not supported', $site['body']['message']); + $this->assertStringContainsString('Runtime "node-24" is not supported', (string) $site['body']['message']); $this->cleanupSite($siteId); }