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 <cursoragent@cursor.com>
This commit is contained in:
Chirag AggarwalandCursor committed 2026-07-10 16:49:11 +05:30
1 parent 43265d6683
commit 43eb0d1092
3 files changed
+21

No files matched your search

@@ -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([
@@ -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);
@@ -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);