From 43eb0d10929b3560754192ac88c1b969c32f0137 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Fri, 10 Jul 2026 16:49:11 +0530 Subject: [PATCH] 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);