From 6797986574fd0a17749cbd339a73fd7eca41c121 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Tue, 2 Jun 2026 17:31:58 +0400 Subject: [PATCH 01/13] Update default site build specification --- app/config/collections/projects.php | 2 +- app/init/constants.php | 1 + .../Platform/Modules/Compute/Base.php | 15 ++++++++----- .../Compute/Validator/Specification.php | 9 +++++--- .../Modules/Sites/Http/Sites/Create.php | 5 +++-- .../Modules/Sites/Http/Sites/Update.php | 5 +++-- .../Services/Sites/SitesCustomServerTest.php | 1 + .../Compute/Validator/SpecificationTest.php | 22 +++++++++++++++++++ 8 files changed, 47 insertions(+), 13 deletions(-) diff --git a/app/config/collections/projects.php b/app/config/collections/projects.php index 9ac5c562e3..95f78bcb12 100644 --- a/app/config/collections/projects.php +++ b/app/config/collections/projects.php @@ -1306,7 +1306,7 @@ return [ 'size' => 128, 'signed' => false, 'required' => false, - 'default' => APP_COMPUTE_SPECIFICATION_DEFAULT, + 'default' => APP_SITES_BUILD_SPECIFICATION_DEFAULT, 'filters' => [], ], [ diff --git a/app/init/constants.php b/app/init/constants.php index d426e51fb6..545f3acafa 100644 --- a/app/init/constants.php +++ b/app/init/constants.php @@ -98,6 +98,7 @@ const APP_SOCIAL_YOUTUBE = 'https://www.youtube.com/c/appwrite?sub_confirmation= const APP_COMPUTE_CPUS_DEFAULT = 0.5; const APP_COMPUTE_MEMORY_DEFAULT = 512; const APP_COMPUTE_SPECIFICATION_DEFAULT = Specification::S_1VCPU_512MB; +const APP_SITES_BUILD_SPECIFICATION_DEFAULT = Specification::S_2VCPU_2GB; const APP_COMPUTE_DEPLOYMENT_MAX_RETENTION = 100 * 365; // 100 years const APP_SDK_PLATFORM_SERVER = 'server'; const APP_SDK_PLATFORM_CLIENT = 'client'; diff --git a/src/Appwrite/Platform/Modules/Compute/Base.php b/src/Appwrite/Platform/Modules/Compute/Base.php index b0efac3829..f7bc954bd7 100644 --- a/src/Appwrite/Platform/Modules/Compute/Base.php +++ b/src/Appwrite/Platform/Modules/Compute/Base.php @@ -33,29 +33,34 @@ class Base extends Action * @param array $plan The billing plan configuration * @return string The appropriate default specification */ - protected function getDefaultSpecification(array $plan): string + protected function getDefaultSpecification(array $plan, string $planKey = 'runtimeSpecifications', string $fallback = APP_COMPUTE_SPECIFICATION_DEFAULT, bool $preferFallback = false): string { $specifications = Config::getParam('specifications', []); if (empty($specifications)) { - return APP_COMPUTE_SPECIFICATION_DEFAULT; + return $fallback; } $specificationValidator = new SpecificationValidator( $plan, $specifications, System::getEnv('_APP_COMPUTE_CPUS', 0), - System::getEnv('_APP_COMPUTE_MEMORY', 0) + System::getEnv('_APP_COMPUTE_MEMORY', 0), + $planKey ); $allowedSpecifications = $specificationValidator->getAllowedSpecifications(); + if ($preferFallback && !array_key_exists($planKey, $plan) && \in_array($fallback, $allowedSpecifications)) { + return $fallback; + } + // If there is no plan use the highest specification if (empty($plan)) { - return end($allowedSpecifications) ?? APP_COMPUTE_SPECIFICATION_DEFAULT; + return end($allowedSpecifications) ?? $fallback; } // Otherwise, use the lowest specification available in the plan - return $allowedSpecifications[0] ?? APP_COMPUTE_SPECIFICATION_DEFAULT; + return $allowedSpecifications[0] ?? $fallback; } public function redeployVcsFunction(Request $request, Document $function, Document $project, Document $installation, Database $dbForProject, BuildPublisher $publisherForBuilds, Document $template, GitHub $github, bool $activate, array $platform = [], string $referenceType = 'branch', string $reference = ''): Document diff --git a/src/Appwrite/Platform/Modules/Compute/Validator/Specification.php b/src/Appwrite/Platform/Modules/Compute/Validator/Specification.php index 5c6cf9ce1f..5f1337c97f 100644 --- a/src/Appwrite/Platform/Modules/Compute/Validator/Specification.php +++ b/src/Appwrite/Platform/Modules/Compute/Validator/Specification.php @@ -14,12 +14,15 @@ class Specification extends Validator private int $maxMemory; - public function __construct(array $plan, array $specifications, float $maxCpus, int $maxMemory) + private string $planKey; + + public function __construct(array $plan, array $specifications, float $maxCpus, int $maxMemory, string $planKey = 'runtimeSpecifications') { $this->plan = $plan; $this->specifications = $specifications; $this->maxCpus = $maxCpus; $this->maxMemory = $maxMemory; + $this->planKey = $planKey; } /** @@ -35,8 +38,8 @@ class Specification extends Validator foreach ($this->specifications as $size => $values) { if ((empty($this->maxCpus) || $values['cpus'] <= $this->maxCpus) && (empty($this->maxMemory) || $values['memory'] <= $this->maxMemory)) { - if (!empty($this->plan) && array_key_exists('runtimeSpecifications', $this->plan)) { - if (!\in_array($size, $this->plan['runtimeSpecifications'])) { + if (!empty($this->plan) && array_key_exists($this->planKey, $this->plan)) { + if (!\in_array($size, $this->plan[$this->planKey])) { continue; } } diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Create.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Create.php index e167c88af2..3662bb4d35 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Create.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Create.php @@ -82,11 +82,12 @@ class Create extends Base ->param('providerRootDirectory', '', new Text(128, 0), 'Path to site code in the linked repo.', true) ->param('providerBranches', [], new ArrayList(new Text(128), APP_LIMIT_ARRAY_PARAMS_SIZE), 'List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches.', true) ->param('providerPaths', [], new ArrayList(new Text(128), APP_LIMIT_ARRAY_PARAMS_SIZE), 'List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes.', true) - ->param('buildSpecification', fn (array $plan) => $this->getDefaultSpecification($plan), fn (array $plan) => new Specification( + ->param('buildSpecification', fn (array $plan) => $this->getDefaultSpecification($plan, 'buildSpecifications', APP_SITES_BUILD_SPECIFICATION_DEFAULT, true), fn (array $plan) => new Specification( $plan, Config::getParam('specifications', []), System::getEnv('_APP_COMPUTE_CPUS', 0), - System::getEnv('_APP_COMPUTE_MEMORY', 0) + System::getEnv('_APP_COMPUTE_MEMORY', 0), + 'buildSpecifications' ), 'Build specification for the site deployments.', true, ['plan']) ->param('runtimeSpecification', fn (array $plan) => $this->getDefaultSpecification($plan), fn (array $plan) => new Specification( $plan, diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php index 6cb1905550..0a2f5cdd71 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php @@ -86,11 +86,12 @@ class Update extends Base ->param('providerRootDirectory', '', new Text(128, 0), 'Path to site code in the linked repo.', true) ->param('providerBranches', null, new Nullable(new ArrayList(new Text(128), APP_LIMIT_ARRAY_PARAMS_SIZE)), 'List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches.', true) ->param('providerPaths', null, new Nullable(new ArrayList(new Text(128), APP_LIMIT_ARRAY_PARAMS_SIZE)), 'List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes.', true) - ->param('buildSpecification', fn (array $plan) => $this->getDefaultSpecification($plan), fn (array $plan) => new Specification( + ->param('buildSpecification', fn (array $plan) => $this->getDefaultSpecification($plan, 'buildSpecifications', APP_SITES_BUILD_SPECIFICATION_DEFAULT, true), fn (array $plan) => new Specification( $plan, Config::getParam('specifications', []), System::getEnv('_APP_COMPUTE_CPUS', 0), - System::getEnv('_APP_COMPUTE_MEMORY', 0) + System::getEnv('_APP_COMPUTE_MEMORY', 0), + 'buildSpecifications' ), 'Build specification for the site deployments.', true, ['plan']) ->param('runtimeSpecification', fn (array $plan) => $this->getDefaultSpecification($plan), fn (array $plan) => new Specification( $plan, diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index 9cca689780..914390c354 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -100,6 +100,7 @@ class SitesCustomServerTest extends Scope $this->assertEquals(true, $dateValidator->isValid($site['body']['$createdAt'])); $this->assertEquals(true, $dateValidator->isValid($site['body']['$updatedAt'])); $this->assertEquals('node-22', $site['body']['buildRuntime']); + $this->assertEquals(Specification::S_2VCPU_2GB, $site['body']['buildSpecification']); $this->assertEquals(null, $site['body']['fallbackFile']); $this->assertEquals('./', $site['body']['outputDirectory']); diff --git a/tests/unit/Platform/Modules/Compute/Validator/SpecificationTest.php b/tests/unit/Platform/Modules/Compute/Validator/SpecificationTest.php index 0505494e17..7977212885 100644 --- a/tests/unit/Platform/Modules/Compute/Validator/SpecificationTest.php +++ b/tests/unit/Platform/Modules/Compute/Validator/SpecificationTest.php @@ -72,4 +72,26 @@ class SpecificationTest extends TestCase $this->assertContains(SpecificationConstants::S_05VCPU_512MB, $allowed); $this->assertContains(SpecificationConstants::S_1VCPU_512MB, $allowed); } + + public function testGetAllowedSpecificationsWithBuildPlanLimits(): void + { + $plan = [ + 'buildSpecifications' => [ + SpecificationConstants::S_1VCPU_1GB, + SpecificationConstants::S_2VCPU_2GB, + ] + ]; + $validator = new Specification( + plan: $plan, + specifications: $this->specifications, + maxCpus: 0, + maxMemory: 0, + planKey: 'buildSpecifications' + ); + + $allowed = $validator->getAllowedSpecifications(); + $this->assertCount(2, $allowed); + $this->assertContains(SpecificationConstants::S_1VCPU_1GB, $allowed); + $this->assertContains(SpecificationConstants::S_2VCPU_2GB, $allowed); + } } From aae23cf5a1a74084ccb34849b8ff7a2605112bb3 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Mon, 22 Jun 2026 18:35:02 +0400 Subject: [PATCH 02/13] Fix site build specification defaults --- src/Appwrite/Platform/Modules/Compute/Base.php | 4 ++-- src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php | 5 +++++ tests/e2e/Services/Sites/SitesCustomServerTest.php | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Compute/Base.php b/src/Appwrite/Platform/Modules/Compute/Base.php index 5e1aba372c..8efa6d8843 100644 --- a/src/Appwrite/Platform/Modules/Compute/Base.php +++ b/src/Appwrite/Platform/Modules/Compute/Base.php @@ -56,11 +56,11 @@ class Base extends Action // If there is no plan use the highest specification if (empty($plan)) { - return end($allowedSpecifications) ?? $fallback; + return end($allowedSpecifications) ?: ''; } // Otherwise, use the lowest specification available in the plan - return $allowedSpecifications[0] ?? $fallback; + return $allowedSpecifications[0] ?? ''; } public function redeployVcsFunction(Request $request, Document $function, Document $project, Document $installation, Database $dbForProject, BuildPublisher $publisherForBuilds, Document $template, GitHub $github, bool $activate, array $platform = [], string $referenceType = 'branch', string $reference = ''): Document diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php index 474024fc76..1f6d7cd215 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php @@ -178,6 +178,11 @@ class Update extends Base $framework = $site->getAttribute('framework'); } + $missingParam = new \stdClass(); + if ($request->getPayload('buildSpecification', $missingParam) === $missingParam) { + $buildSpecification = $site->getAttribute('buildSpecification', APP_COMPUTE_SPECIFICATION_DEFAULT); + } + $repositoryId = $site->getAttribute('repositoryId', ''); $repositoryInternalId = $site->getAttribute('repositoryInternalId', ''); diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index c2d69f8cc6..1eee0ecbc8 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -1680,6 +1680,7 @@ final class SitesCustomServerTest extends Scope $this->assertEquals(200, $site['headers']['status-code']); $this->assertNotEmpty($site['body']['$id']); + $this->assertEquals(Specification::S_2VCPU_2GB, $site['body']['buildSpecification']); $this->assertEquals(Specification::S_1VCPU_1GB, $site['body']['runtimeSpecification']); // Change the specs to 1vcpu 512mb @@ -1697,6 +1698,7 @@ final class SitesCustomServerTest extends Scope $this->assertEquals(200, $site['headers']['status-code']); $this->assertNotEmpty($site['body']['$id']); + $this->assertEquals(Specification::S_2VCPU_2GB, $site['body']['buildSpecification']); $this->assertEquals(Specification::S_1VCPU_512MB, $site['body']['runtimeSpecification']); /** From 419cd2e35638d1d2561343939d613d106a277cf6 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Mon, 22 Jun 2026 19:10:28 +0400 Subject: [PATCH 03/13] Expose build enabled specifications --- .../Modules/Functions/Http/Specifications/XList.php | 4 ++++ .../Platform/Modules/Sites/Http/Specifications/XList.php | 4 ++++ src/Appwrite/Utopia/Response/Model/Specification.php | 8 +++++++- .../e2e/Services/Functions/FunctionsCustomServerTest.php | 2 ++ tests/e2e/Services/Sites/SitesCustomServerTest.php | 2 ++ 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Specifications/XList.php b/src/Appwrite/Platform/Modules/Functions/Http/Specifications/XList.php index d76584534d..498a274280 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Specifications/XList.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Specifications/XList.php @@ -58,10 +58,14 @@ class XList extends Base $specs = []; foreach ($allSpecs as $spec) { $spec['enabled'] = true; + $spec['buildEnabled'] = true; if (array_key_exists('runtimeSpecifications', $plan)) { $spec['enabled'] = in_array($spec['slug'], $plan['runtimeSpecifications']); } + if (array_key_exists('buildSpecifications', $plan)) { + $spec['buildEnabled'] = in_array($spec['slug'], $plan['buildSpecifications']); + } $maxCpus = System::getEnv('_APP_COMPUTE_CPUS', 0); $maxMemory = System::getEnv('_APP_COMPUTE_MEMORY', 0); diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Specifications/XList.php b/src/Appwrite/Platform/Modules/Sites/Http/Specifications/XList.php index 4bda37df73..d5b6515de7 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Specifications/XList.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Specifications/XList.php @@ -58,10 +58,14 @@ class XList extends Base $specs = []; foreach ($allSpecs as $spec) { $spec['enabled'] = true; + $spec['buildEnabled'] = true; if (array_key_exists('runtimeSpecifications', $plan)) { $spec['enabled'] = in_array($spec['slug'], $plan['runtimeSpecifications']); } + if (array_key_exists('buildSpecifications', $plan)) { + $spec['buildEnabled'] = in_array($spec['slug'], $plan['buildSpecifications']); + } $maxCpus = System::getEnv('_APP_COMPUTE_CPUS', 0); $maxMemory = System::getEnv('_APP_COMPUTE_MEMORY', 0); diff --git a/src/Appwrite/Utopia/Response/Model/Specification.php b/src/Appwrite/Utopia/Response/Model/Specification.php index 4fa7fb9bc7..034d399a75 100644 --- a/src/Appwrite/Utopia/Response/Model/Specification.php +++ b/src/Appwrite/Utopia/Response/Model/Specification.php @@ -24,7 +24,13 @@ class Specification extends Model ]); $this->addRule('enabled', [ 'type' => self::TYPE_BOOLEAN, - 'description' => 'Is size enabled.', + 'description' => 'Is size enabled for runtime.', + 'default' => false, + 'example' => true + ]); + $this->addRule('buildEnabled', [ + 'type' => self::TYPE_BOOLEAN, + 'description' => 'Is size enabled for builds.', 'default' => false, 'example' => true ]); diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 1aba466944..86aa67df32 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -208,10 +208,12 @@ final class FunctionsCustomServerTest extends Scope $this->assertArrayHasKey('memory', $specifications['body']['specifications'][0]); $this->assertArrayHasKey('cpus', $specifications['body']['specifications'][0]); $this->assertArrayHasKey('enabled', $specifications['body']['specifications'][0]); + $this->assertArrayHasKey('buildEnabled', $specifications['body']['specifications'][0]); $this->assertArrayHasKey('slug', $specifications['body']['specifications'][0]); $this->assertArrayHasKey('memory', $specifications['body']['specifications'][1]); $this->assertArrayHasKey('cpus', $specifications['body']['specifications'][1]); $this->assertArrayHasKey('enabled', $specifications['body']['specifications'][1]); + $this->assertArrayHasKey('buildEnabled', $specifications['body']['specifications'][1]); $this->assertArrayHasKey('slug', $specifications['body']['specifications'][1]); $function = $this->createFunction([ diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index 1eee0ecbc8..8a326d1023 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -34,10 +34,12 @@ final class SitesCustomServerTest extends Scope $this->assertArrayHasKey('memory', $specifications['body']['specifications'][0]); $this->assertArrayHasKey('cpus', $specifications['body']['specifications'][0]); $this->assertArrayHasKey('enabled', $specifications['body']['specifications'][0]); + $this->assertArrayHasKey('buildEnabled', $specifications['body']['specifications'][0]); $this->assertArrayHasKey('slug', $specifications['body']['specifications'][0]); $this->assertArrayHasKey('memory', $specifications['body']['specifications'][1]); $this->assertArrayHasKey('cpus', $specifications['body']['specifications'][1]); $this->assertArrayHasKey('enabled', $specifications['body']['specifications'][1]); + $this->assertArrayHasKey('buildEnabled', $specifications['body']['specifications'][1]); $this->assertArrayHasKey('slug', $specifications['body']['specifications'][1]); $site = $this->createSite([ From 7f536750b4ea92799515cd3ae368a1baed06eba6 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Mon, 22 Jun 2026 19:18:53 +0400 Subject: [PATCH 04/13] Rename build specification availability field --- .../Platform/Modules/Functions/Http/Specifications/XList.php | 4 ++-- .../Platform/Modules/Sites/Http/Specifications/XList.php | 4 ++-- src/Appwrite/Utopia/Response/Model/Specification.php | 2 +- tests/e2e/Services/Functions/FunctionsCustomServerTest.php | 4 ++-- tests/e2e/Services/Sites/SitesCustomServerTest.php | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Specifications/XList.php b/src/Appwrite/Platform/Modules/Functions/Http/Specifications/XList.php index 498a274280..53d52cccb5 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Specifications/XList.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Specifications/XList.php @@ -58,13 +58,13 @@ class XList extends Base $specs = []; foreach ($allSpecs as $spec) { $spec['enabled'] = true; - $spec['buildEnabled'] = true; + $spec['enabledForBuilds'] = true; if (array_key_exists('runtimeSpecifications', $plan)) { $spec['enabled'] = in_array($spec['slug'], $plan['runtimeSpecifications']); } if (array_key_exists('buildSpecifications', $plan)) { - $spec['buildEnabled'] = in_array($spec['slug'], $plan['buildSpecifications']); + $spec['enabledForBuilds'] = in_array($spec['slug'], $plan['buildSpecifications']); } $maxCpus = System::getEnv('_APP_COMPUTE_CPUS', 0); diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Specifications/XList.php b/src/Appwrite/Platform/Modules/Sites/Http/Specifications/XList.php index d5b6515de7..86904e8f67 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Specifications/XList.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Specifications/XList.php @@ -58,13 +58,13 @@ class XList extends Base $specs = []; foreach ($allSpecs as $spec) { $spec['enabled'] = true; - $spec['buildEnabled'] = true; + $spec['enabledForBuilds'] = true; if (array_key_exists('runtimeSpecifications', $plan)) { $spec['enabled'] = in_array($spec['slug'], $plan['runtimeSpecifications']); } if (array_key_exists('buildSpecifications', $plan)) { - $spec['buildEnabled'] = in_array($spec['slug'], $plan['buildSpecifications']); + $spec['enabledForBuilds'] = in_array($spec['slug'], $plan['buildSpecifications']); } $maxCpus = System::getEnv('_APP_COMPUTE_CPUS', 0); diff --git a/src/Appwrite/Utopia/Response/Model/Specification.php b/src/Appwrite/Utopia/Response/Model/Specification.php index 034d399a75..74188a533a 100644 --- a/src/Appwrite/Utopia/Response/Model/Specification.php +++ b/src/Appwrite/Utopia/Response/Model/Specification.php @@ -28,7 +28,7 @@ class Specification extends Model 'default' => false, 'example' => true ]); - $this->addRule('buildEnabled', [ + $this->addRule('enabledForBuilds', [ 'type' => self::TYPE_BOOLEAN, 'description' => 'Is size enabled for builds.', 'default' => false, diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 86aa67df32..aba9ec2104 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -208,12 +208,12 @@ final class FunctionsCustomServerTest extends Scope $this->assertArrayHasKey('memory', $specifications['body']['specifications'][0]); $this->assertArrayHasKey('cpus', $specifications['body']['specifications'][0]); $this->assertArrayHasKey('enabled', $specifications['body']['specifications'][0]); - $this->assertArrayHasKey('buildEnabled', $specifications['body']['specifications'][0]); + $this->assertArrayHasKey('enabledForBuilds', $specifications['body']['specifications'][0]); $this->assertArrayHasKey('slug', $specifications['body']['specifications'][0]); $this->assertArrayHasKey('memory', $specifications['body']['specifications'][1]); $this->assertArrayHasKey('cpus', $specifications['body']['specifications'][1]); $this->assertArrayHasKey('enabled', $specifications['body']['specifications'][1]); - $this->assertArrayHasKey('buildEnabled', $specifications['body']['specifications'][1]); + $this->assertArrayHasKey('enabledForBuilds', $specifications['body']['specifications'][1]); $this->assertArrayHasKey('slug', $specifications['body']['specifications'][1]); $function = $this->createFunction([ diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index 8a326d1023..c5e27cd324 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -34,12 +34,12 @@ final class SitesCustomServerTest extends Scope $this->assertArrayHasKey('memory', $specifications['body']['specifications'][0]); $this->assertArrayHasKey('cpus', $specifications['body']['specifications'][0]); $this->assertArrayHasKey('enabled', $specifications['body']['specifications'][0]); - $this->assertArrayHasKey('buildEnabled', $specifications['body']['specifications'][0]); + $this->assertArrayHasKey('enabledForBuilds', $specifications['body']['specifications'][0]); $this->assertArrayHasKey('slug', $specifications['body']['specifications'][0]); $this->assertArrayHasKey('memory', $specifications['body']['specifications'][1]); $this->assertArrayHasKey('cpus', $specifications['body']['specifications'][1]); $this->assertArrayHasKey('enabled', $specifications['body']['specifications'][1]); - $this->assertArrayHasKey('buildEnabled', $specifications['body']['specifications'][1]); + $this->assertArrayHasKey('enabledForBuilds', $specifications['body']['specifications'][1]); $this->assertArrayHasKey('slug', $specifications['body']['specifications'][1]); $site = $this->createSite([ From 23be75a87fd4679d83a0a35d5dd7bff5ac597f93 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Mon, 22 Jun 2026 19:51:26 +0400 Subject: [PATCH 05/13] Add specification type parameter --- .../Modules/Functions/Http/Specifications/XList.php | 13 ++++++------- .../Modules/Sites/Http/Specifications/XList.php | 13 ++++++------- .../Utopia/Response/Model/Specification.php | 8 +------- tests/e2e/Services/Functions/FunctionsBase.php | 4 ++-- .../Functions/FunctionsCustomServerTest.php | 12 +++++++----- tests/e2e/Services/Sites/SitesBase.php | 4 ++-- tests/e2e/Services/Sites/SitesCustomServerTest.php | 12 +++++++----- 7 files changed, 31 insertions(+), 35 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Specifications/XList.php b/src/Appwrite/Platform/Modules/Functions/Http/Specifications/XList.php index 53d52cccb5..8cbff906fa 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Specifications/XList.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Specifications/XList.php @@ -12,6 +12,7 @@ use Utopia\Database\Document; use Utopia\Platform\Action; use Utopia\Platform\Scope\HTTP; use Utopia\System\System; +use Utopia\Validator\WhiteList; class XList extends Base { @@ -46,25 +47,23 @@ class XList extends Base ) ] )) + ->param('type', 'runtimes', new WhiteList(['runtimes', 'builds']), 'Specification type to list. Can be one of: runtimes, builds.', true) ->inject('response') ->inject('plan') ->callback($this->action(...)); } - public function action(Response $response, array $plan) + public function action(string $type, Response $response, array $plan) { $allSpecs = Config::getParam('specifications', []); + $planKey = $type === 'builds' ? 'buildSpecifications' : 'runtimeSpecifications'; $specs = []; foreach ($allSpecs as $spec) { $spec['enabled'] = true; - $spec['enabledForBuilds'] = true; - if (array_key_exists('runtimeSpecifications', $plan)) { - $spec['enabled'] = in_array($spec['slug'], $plan['runtimeSpecifications']); - } - if (array_key_exists('buildSpecifications', $plan)) { - $spec['enabledForBuilds'] = in_array($spec['slug'], $plan['buildSpecifications']); + if (array_key_exists($planKey, $plan)) { + $spec['enabled'] = in_array($spec['slug'], $plan[$planKey]); } $maxCpus = System::getEnv('_APP_COMPUTE_CPUS', 0); diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Specifications/XList.php b/src/Appwrite/Platform/Modules/Sites/Http/Specifications/XList.php index 86904e8f67..a4f865d859 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Specifications/XList.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Specifications/XList.php @@ -12,6 +12,7 @@ use Utopia\Database\Document; use Utopia\Platform\Action; use Utopia\Platform\Scope\HTTP; use Utopia\System\System; +use Utopia\Validator\WhiteList; class XList extends Base { @@ -46,25 +47,23 @@ class XList extends Base ) ] )) + ->param('type', 'runtimes', new WhiteList(['runtimes', 'builds']), 'Specification type to list. Can be one of: runtimes, builds.', true) ->inject('response') ->inject('plan') ->callback($this->action(...)); } - public function action(Response $response, array $plan) + public function action(string $type, Response $response, array $plan) { $allSpecs = Config::getParam('specifications', []); + $planKey = $type === 'builds' ? 'buildSpecifications' : 'runtimeSpecifications'; $specs = []; foreach ($allSpecs as $spec) { $spec['enabled'] = true; - $spec['enabledForBuilds'] = true; - if (array_key_exists('runtimeSpecifications', $plan)) { - $spec['enabled'] = in_array($spec['slug'], $plan['runtimeSpecifications']); - } - if (array_key_exists('buildSpecifications', $plan)) { - $spec['enabledForBuilds'] = in_array($spec['slug'], $plan['buildSpecifications']); + if (array_key_exists($planKey, $plan)) { + $spec['enabled'] = in_array($spec['slug'], $plan[$planKey]); } $maxCpus = System::getEnv('_APP_COMPUTE_CPUS', 0); diff --git a/src/Appwrite/Utopia/Response/Model/Specification.php b/src/Appwrite/Utopia/Response/Model/Specification.php index 74188a533a..4fa7fb9bc7 100644 --- a/src/Appwrite/Utopia/Response/Model/Specification.php +++ b/src/Appwrite/Utopia/Response/Model/Specification.php @@ -24,13 +24,7 @@ class Specification extends Model ]); $this->addRule('enabled', [ 'type' => self::TYPE_BOOLEAN, - 'description' => 'Is size enabled for runtime.', - 'default' => false, - 'example' => true - ]); - $this->addRule('enabledForBuilds', [ - 'type' => self::TYPE_BOOLEAN, - 'description' => 'Is size enabled for builds.', + 'description' => 'Is size enabled.', 'default' => false, 'example' => true ]); diff --git a/tests/e2e/Services/Functions/FunctionsBase.php b/tests/e2e/Services/Functions/FunctionsBase.php index 458359bbe9..05f2e52c1a 100644 --- a/tests/e2e/Services/Functions/FunctionsBase.php +++ b/tests/e2e/Services/Functions/FunctionsBase.php @@ -494,11 +494,11 @@ trait FunctionsBase return $deployment; } - protected function listSpecifications(): mixed + protected function listSpecifications(array $params = []): mixed { $specifications = $this->client->call(Client::METHOD_GET, '/functions/specifications', array_merge([ 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders())); + ], $this->getHeaders()), $params); return $specifications; } diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index aba9ec2104..80578d443b 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -208,28 +208,30 @@ final class FunctionsCustomServerTest extends Scope $this->assertArrayHasKey('memory', $specifications['body']['specifications'][0]); $this->assertArrayHasKey('cpus', $specifications['body']['specifications'][0]); $this->assertArrayHasKey('enabled', $specifications['body']['specifications'][0]); - $this->assertArrayHasKey('enabledForBuilds', $specifications['body']['specifications'][0]); $this->assertArrayHasKey('slug', $specifications['body']['specifications'][0]); $this->assertArrayHasKey('memory', $specifications['body']['specifications'][1]); $this->assertArrayHasKey('cpus', $specifications['body']['specifications'][1]); $this->assertArrayHasKey('enabled', $specifications['body']['specifications'][1]); - $this->assertArrayHasKey('enabledForBuilds', $specifications['body']['specifications'][1]); $this->assertArrayHasKey('slug', $specifications['body']['specifications'][1]); + $buildSpecifications = $this->listSpecifications(['type' => 'builds']); + $this->assertEquals(200, $buildSpecifications['headers']['status-code']); + $this->assertEquals($specifications['body']['total'], $buildSpecifications['body']['total']); + $function = $this->createFunction([ 'functionId' => ID::unique(), 'name' => 'Specs function', 'runtime' => 'node-22', - 'buildSpecification' => $specifications['body']['specifications'][0]['slug'], + 'buildSpecification' => $buildSpecifications['body']['specifications'][0]['slug'], 'runtimeSpecification' => $specifications['body']['specifications'][1]['slug'], ]); $this->assertEquals(201, $function['headers']['status-code']); - $this->assertEquals($specifications['body']['specifications'][0]['slug'], $function['body']['buildSpecification']); + $this->assertEquals($buildSpecifications['body']['specifications'][0]['slug'], $function['body']['buildSpecification']); $this->assertEquals($specifications['body']['specifications'][1]['slug'], $function['body']['runtimeSpecification']); $function = $this->getFunction($function['body']['$id']); $this->assertEquals(200, $function['headers']['status-code']); - $this->assertEquals($specifications['body']['specifications'][0]['slug'], $function['body']['buildSpecification']); + $this->assertEquals($buildSpecifications['body']['specifications'][0]['slug'], $function['body']['buildSpecification']); $this->assertEquals($specifications['body']['specifications'][1]['slug'], $function['body']['runtimeSpecification']); $this->cleanupFunction($function['body']['$id']); diff --git a/tests/e2e/Services/Sites/SitesBase.php b/tests/e2e/Services/Sites/SitesBase.php index 54344f649a..f6a29f82ab 100644 --- a/tests/e2e/Services/Sites/SitesBase.php +++ b/tests/e2e/Services/Sites/SitesBase.php @@ -489,11 +489,11 @@ trait SitesBase return $deployment; } - protected function listSpecifications(): mixed + protected function listSpecifications(array $params = []): mixed { $specifications = $this->client->call(Client::METHOD_GET, '/sites/specifications', array_merge([ 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders())); + ], $this->getHeaders()), $params); return $specifications; } diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index c5e27cd324..102f828441 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -34,29 +34,31 @@ final class SitesCustomServerTest extends Scope $this->assertArrayHasKey('memory', $specifications['body']['specifications'][0]); $this->assertArrayHasKey('cpus', $specifications['body']['specifications'][0]); $this->assertArrayHasKey('enabled', $specifications['body']['specifications'][0]); - $this->assertArrayHasKey('enabledForBuilds', $specifications['body']['specifications'][0]); $this->assertArrayHasKey('slug', $specifications['body']['specifications'][0]); $this->assertArrayHasKey('memory', $specifications['body']['specifications'][1]); $this->assertArrayHasKey('cpus', $specifications['body']['specifications'][1]); $this->assertArrayHasKey('enabled', $specifications['body']['specifications'][1]); - $this->assertArrayHasKey('enabledForBuilds', $specifications['body']['specifications'][1]); $this->assertArrayHasKey('slug', $specifications['body']['specifications'][1]); + $buildSpecifications = $this->listSpecifications(['type' => 'builds']); + $this->assertEquals(200, $buildSpecifications['headers']['status-code']); + $this->assertEquals($specifications['body']['total'], $buildSpecifications['body']['total']); + $site = $this->createSite([ 'buildRuntime' => 'node-22', 'framework' => 'other', 'name' => 'Specs site', 'siteId' => ID::unique(), - 'buildSpecification' => $specifications['body']['specifications'][0]['slug'], + 'buildSpecification' => $buildSpecifications['body']['specifications'][0]['slug'], 'runtimeSpecification' => $specifications['body']['specifications'][1]['slug'], ]); $this->assertEquals(201, $site['headers']['status-code']); - $this->assertEquals($specifications['body']['specifications'][0]['slug'], $site['body']['buildSpecification']); + $this->assertEquals($buildSpecifications['body']['specifications'][0]['slug'], $site['body']['buildSpecification']); $this->assertEquals($specifications['body']['specifications'][1]['slug'], $site['body']['runtimeSpecification']); $site = $this->getSite($site['body']['$id']); $this->assertEquals(200, $site['headers']['status-code']); - $this->assertEquals($specifications['body']['specifications'][0]['slug'], $site['body']['buildSpecification']); + $this->assertEquals($buildSpecifications['body']['specifications'][0]['slug'], $site['body']['buildSpecification']); $this->assertEquals($specifications['body']['specifications'][1]['slug'], $site['body']['runtimeSpecification']); $this->cleanupSite($site['body']['$id']); From bd9855587628b4c53bf5efec57b4086227e00547 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Mon, 22 Jun 2026 22:06:56 +0400 Subject: [PATCH 06/13] Make specification tests explicit --- src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php | 5 ----- tests/e2e/Services/Functions/FunctionsCustomServerTest.php | 2 +- tests/e2e/Services/Sites/SitesCustomServerTest.php | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php index 1f6d7cd215..474024fc76 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php @@ -178,11 +178,6 @@ class Update extends Base $framework = $site->getAttribute('framework'); } - $missingParam = new \stdClass(); - if ($request->getPayload('buildSpecification', $missingParam) === $missingParam) { - $buildSpecification = $site->getAttribute('buildSpecification', APP_COMPUTE_SPECIFICATION_DEFAULT); - } - $repositoryId = $site->getAttribute('repositoryId', ''); $repositoryInternalId = $site->getAttribute('repositoryInternalId', ''); diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 80578d443b..87635d55c3 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -200,7 +200,7 @@ final class FunctionsCustomServerTest extends Scope public function testListSpecs(): void { - $specifications = $this->listSpecifications(); + $specifications = $this->listSpecifications(['type' => 'runtimes']); $this->assertEquals(200, $specifications['headers']['status-code']); $this->assertGreaterThanOrEqual(2, $specifications['body']['total']); $this->assertArrayHasKey(0, $specifications['body']['specifications']); diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index 102f828441..5b09b4b45c 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -26,7 +26,7 @@ final class SitesCustomServerTest extends Scope public function testListSpecs(): void { - $specifications = $this->listSpecifications(); + $specifications = $this->listSpecifications(['type' => 'runtimes']); $this->assertEquals(200, $specifications['headers']['status-code']); $this->assertGreaterThanOrEqual(2, $specifications['body']['total']); $this->assertArrayHasKey(0, $specifications['body']['specifications']); From a7fc66ef3e47dc1214973acfa6e2963dab39b647 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Mon, 22 Jun 2026 22:34:04 +0400 Subject: [PATCH 07/13] Use listed build specs in tests --- .../Functions/FunctionsCustomServerTest.php | 7 ++--- .../Services/Sites/SitesCustomServerTest.php | 27 ++++++++++++++----- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 87635d55c3..0e98be1d25 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -217,21 +217,22 @@ final class FunctionsCustomServerTest extends Scope $buildSpecifications = $this->listSpecifications(['type' => 'builds']); $this->assertEquals(200, $buildSpecifications['headers']['status-code']); $this->assertEquals($specifications['body']['total'], $buildSpecifications['body']['total']); + $buildSpecification = $buildSpecifications['body']['specifications'][0]['slug']; $function = $this->createFunction([ 'functionId' => ID::unique(), 'name' => 'Specs function', 'runtime' => 'node-22', - 'buildSpecification' => $buildSpecifications['body']['specifications'][0]['slug'], + 'buildSpecification' => $buildSpecification, 'runtimeSpecification' => $specifications['body']['specifications'][1]['slug'], ]); $this->assertEquals(201, $function['headers']['status-code']); - $this->assertEquals($buildSpecifications['body']['specifications'][0]['slug'], $function['body']['buildSpecification']); + $this->assertEquals($buildSpecification, $function['body']['buildSpecification']); $this->assertEquals($specifications['body']['specifications'][1]['slug'], $function['body']['runtimeSpecification']); $function = $this->getFunction($function['body']['$id']); $this->assertEquals(200, $function['headers']['status-code']); - $this->assertEquals($buildSpecifications['body']['specifications'][0]['slug'], $function['body']['buildSpecification']); + $this->assertEquals($buildSpecification, $function['body']['buildSpecification']); $this->assertEquals($specifications['body']['specifications'][1]['slug'], $function['body']['runtimeSpecification']); $this->cleanupFunction($function['body']['$id']); diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index 5b09b4b45c..a2bf0771ca 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -43,22 +43,23 @@ final class SitesCustomServerTest extends Scope $buildSpecifications = $this->listSpecifications(['type' => 'builds']); $this->assertEquals(200, $buildSpecifications['headers']['status-code']); $this->assertEquals($specifications['body']['total'], $buildSpecifications['body']['total']); + $buildSpecification = $buildSpecifications['body']['specifications'][0]['slug']; $site = $this->createSite([ 'buildRuntime' => 'node-22', 'framework' => 'other', 'name' => 'Specs site', 'siteId' => ID::unique(), - 'buildSpecification' => $buildSpecifications['body']['specifications'][0]['slug'], + 'buildSpecification' => $buildSpecification, 'runtimeSpecification' => $specifications['body']['specifications'][1]['slug'], ]); $this->assertEquals(201, $site['headers']['status-code']); - $this->assertEquals($buildSpecifications['body']['specifications'][0]['slug'], $site['body']['buildSpecification']); + $this->assertEquals($buildSpecification, $site['body']['buildSpecification']); $this->assertEquals($specifications['body']['specifications'][1]['slug'], $site['body']['runtimeSpecification']); $site = $this->getSite($site['body']['$id']); $this->assertEquals(200, $site['headers']['status-code']); - $this->assertEquals($buildSpecifications['body']['specifications'][0]['slug'], $site['body']['buildSpecification']); + $this->assertEquals($buildSpecification, $site['body']['buildSpecification']); $this->assertEquals($specifications['body']['specifications'][1]['slug'], $site['body']['runtimeSpecification']); $this->cleanupSite($site['body']['$id']); @@ -84,11 +85,15 @@ final class SitesCustomServerTest extends Scope public function testCreateSite(): void { + $buildSpecifications = $this->listSpecifications(['type' => 'builds']); + $buildSpecification = $buildSpecifications['body']['specifications'][0]['slug']; + /** * Test for SUCCESS */ $site = $this->createSite([ 'buildRuntime' => 'node-22', + 'buildSpecification' => $buildSpecification, 'fallbackFile' => '', 'framework' => 'other', 'name' => 'Test Site', @@ -106,7 +111,7 @@ final class SitesCustomServerTest extends Scope $this->assertEquals(true, $dateValidator->isValid($site['body']['$createdAt'])); $this->assertEquals(true, $dateValidator->isValid($site['body']['$updatedAt'])); $this->assertEquals('node-22', $site['body']['buildRuntime']); - $this->assertEquals(Specification::S_2VCPU_2GB, $site['body']['buildSpecification']); + $this->assertEquals($buildSpecification, $site['body']['buildSpecification']); $this->assertEquals(null, $site['body']['fallbackFile']); $this->assertEquals('./', $site['body']['outputDirectory']); @@ -721,11 +726,14 @@ final class SitesCustomServerTest extends Scope public function testListSites(): void { + $buildSpecifications = $this->listSpecifications(['type' => 'builds']); + /** * Test for SUCCESS */ $siteId = $this->setupSite([ 'buildRuntime' => 'node-22', + 'buildSpecification' => $buildSpecifications['body']['specifications'][0]['slug'], 'fallbackFile' => '', 'framework' => 'analog', 'name' => 'Test List Sites', @@ -867,8 +875,11 @@ final class SitesCustomServerTest extends Scope public function testGetSite(): void { + $buildSpecifications = $this->listSpecifications(['type' => 'builds']); + $siteId = $this->setupSite([ 'buildRuntime' => 'node-22', + 'buildSpecification' => $buildSpecifications['body']['specifications'][0]['slug'], 'fallbackFile' => '', 'framework' => 'other', 'name' => 'Test Site', @@ -1655,8 +1666,12 @@ final class SitesCustomServerTest extends Scope public function testUpdateSpecs(): void { + $buildSpecifications = $this->listSpecifications(['type' => 'builds']); + $buildSpecification = $buildSpecifications['body']['specifications'][0]['slug']; + $siteId = $this->setupSite([ 'buildRuntime' => 'node-22', + 'buildSpecification' => $buildSpecification, 'fallbackFile' => '', 'framework' => 'other', 'name' => 'Test Site', @@ -1684,7 +1699,7 @@ final class SitesCustomServerTest extends Scope $this->assertEquals(200, $site['headers']['status-code']); $this->assertNotEmpty($site['body']['$id']); - $this->assertEquals(Specification::S_2VCPU_2GB, $site['body']['buildSpecification']); + $this->assertEquals($buildSpecification, $site['body']['buildSpecification']); $this->assertEquals(Specification::S_1VCPU_1GB, $site['body']['runtimeSpecification']); // Change the specs to 1vcpu 512mb @@ -1702,7 +1717,7 @@ final class SitesCustomServerTest extends Scope $this->assertEquals(200, $site['headers']['status-code']); $this->assertNotEmpty($site['body']['$id']); - $this->assertEquals(Specification::S_2VCPU_2GB, $site['body']['buildSpecification']); + $this->assertEquals($buildSpecification, $site['body']['buildSpecification']); $this->assertEquals(Specification::S_1VCPU_512MB, $site['body']['runtimeSpecification']); /** From ea574f9909380b049a7bfe2b48330cc150197e99 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Mon, 22 Jun 2026 22:44:22 +0400 Subject: [PATCH 08/13] Pass build spec explicitly in site update test --- tests/e2e/Services/Sites/SitesCustomServerTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index a2bf0771ca..436afea1bd 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -1687,6 +1687,7 @@ final class SitesCustomServerTest extends Scope // Change the function specs $site = $this->updateSite([ 'buildRuntime' => 'node-22', + 'buildSpecification' => $buildSpecification, 'fallbackFile' => '', 'framework' => 'other', 'name' => 'Test Site', @@ -1705,6 +1706,7 @@ final class SitesCustomServerTest extends Scope // Change the specs to 1vcpu 512mb $site = $this->updateSite([ 'buildRuntime' => 'node-22', + 'buildSpecification' => $buildSpecification, 'fallbackFile' => '', 'framework' => 'other', 'name' => 'Test Site', From dc50f940bf1436860d96d3ea5f5e262fe1c3fe02 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Tue, 23 Jun 2026 14:47:06 +0400 Subject: [PATCH 09/13] Fix compute build specification defaults --- src/Appwrite/Platform/Modules/Compute/Base.php | 8 ++++++-- .../Modules/Functions/Http/Functions/Create.php | 5 +++-- .../Modules/Functions/Http/Functions/Update.php | 11 +++++++---- .../Modules/Sites/Http/Sites/Update.php | 8 +++++--- .../Services/Sites/SitesCustomServerTest.php | 17 +++++++++++++++++ 5 files changed, 38 insertions(+), 11 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Compute/Base.php b/src/Appwrite/Platform/Modules/Compute/Base.php index 8efa6d8843..b3740787b3 100644 --- a/src/Appwrite/Platform/Modules/Compute/Base.php +++ b/src/Appwrite/Platform/Modules/Compute/Base.php @@ -50,17 +50,21 @@ class Base extends Action ); $allowedSpecifications = $specificationValidator->getAllowedSpecifications(); + if (empty($allowedSpecifications)) { + return $fallback; + } + if ($preferFallback && !array_key_exists($planKey, $plan) && \in_array($fallback, $allowedSpecifications)) { return $fallback; } // If there is no plan use the highest specification if (empty($plan)) { - return end($allowedSpecifications) ?: ''; + return end($allowedSpecifications); } // Otherwise, use the lowest specification available in the plan - return $allowedSpecifications[0] ?? ''; + return $allowedSpecifications[0]; } public function redeployVcsFunction(Request $request, Document $function, Document $project, Document $installation, Database $dbForProject, BuildPublisher $publisherForBuilds, Document $template, GitHub $github, bool $activate, array $platform = [], string $referenceType = 'branch', string $reference = ''): Document diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Create.php b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Create.php index 2692eaf630..48818dd3ec 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Create.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Create.php @@ -98,11 +98,12 @@ class Create extends Base ->param('providerRootDirectory', '', new Text(128, 0), 'Path to function code in the linked repo.', true) ->param('providerBranches', [], new ArrayList(new Text(128), APP_LIMIT_ARRAY_PARAMS_SIZE), 'List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches.', true) ->param('providerPaths', [], new ArrayList(new Text(128), APP_LIMIT_ARRAY_PARAMS_SIZE), 'List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes.', true) - ->param('buildSpecification', fn (array $plan) => $this->getDefaultSpecification($plan), fn (array $plan) => new Specification( + ->param('buildSpecification', fn (array $plan) => $this->getDefaultSpecification($plan, 'buildSpecifications'), fn (array $plan) => new Specification( $plan, Config::getParam('specifications', []), System::getEnv('_APP_COMPUTE_CPUS', 0), - System::getEnv('_APP_COMPUTE_MEMORY', 0) + System::getEnv('_APP_COMPUTE_MEMORY', 0), + 'buildSpecifications' ), 'Build specification for the function deployments.', true, ['plan']) ->param('runtimeSpecification', fn (array $plan) => $this->getDefaultSpecification($plan), fn (array $plan) => new Specification( $plan, diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php index e9e14a6e22..f23f4bd678 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php @@ -90,12 +90,13 @@ class Update extends Base ->param('providerRootDirectory', '', new Text(128, 0), 'Path to function code in the linked repo.', true) ->param('providerBranches', null, new Nullable(new ArrayList(new Text(128), APP_LIMIT_ARRAY_PARAMS_SIZE)), 'List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches.', true) ->param('providerPaths', null, new Nullable(new ArrayList(new Text(128), APP_LIMIT_ARRAY_PARAMS_SIZE)), 'List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes.', true) - ->param('buildSpecification', fn (array $plan) => $this->getDefaultSpecification($plan), fn (array $plan) => new Specification( + ->param('buildSpecification', null, fn (array $plan) => new Nullable(new Specification( $plan, Config::getParam('specifications', []), System::getEnv('_APP_COMPUTE_CPUS', 0), - System::getEnv('_APP_COMPUTE_MEMORY', 0) - ), 'Build specification for the function deployments.', true, ['plan']) + System::getEnv('_APP_COMPUTE_MEMORY', 0), + 'buildSpecifications' + )), 'Build specification for the function deployments.', true, ['plan']) ->param('runtimeSpecification', fn (array $plan) => $this->getDefaultSpecification($plan), fn (array $plan) => new Specification( $plan, Config::getParam('specifications', []), @@ -137,7 +138,7 @@ class Update extends Base string $providerRootDirectory, ?array $providerBranches, ?array $providerPaths, - string $buildSpecification, + ?string $buildSpecification, string $runtimeSpecification, int $deploymentRetention, Request $request, @@ -173,6 +174,8 @@ class Update extends Base $runtime = $function->getAttribute('runtime'); } + $buildSpecification ??= $function->getAttribute('buildSpecification', APP_COMPUTE_SPECIFICATION_DEFAULT); + $repositoryId = $function->getAttribute('repositoryId', ''); $repositoryInternalId = $function->getAttribute('repositoryInternalId', ''); diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php index 474024fc76..18b38d45af 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php @@ -86,13 +86,13 @@ class Update extends Base ->param('providerRootDirectory', '', new Text(128, 0), 'Path to site code in the linked repo.', true) ->param('providerBranches', null, new Nullable(new ArrayList(new Text(128), APP_LIMIT_ARRAY_PARAMS_SIZE)), 'List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches.', true) ->param('providerPaths', null, new Nullable(new ArrayList(new Text(128), APP_LIMIT_ARRAY_PARAMS_SIZE)), 'List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes.', true) - ->param('buildSpecification', fn (array $plan) => $this->getDefaultSpecification($plan, 'buildSpecifications', APP_SITES_BUILD_SPECIFICATION_DEFAULT, true), fn (array $plan) => new Specification( + ->param('buildSpecification', null, fn (array $plan) => new Nullable(new Specification( $plan, Config::getParam('specifications', []), System::getEnv('_APP_COMPUTE_CPUS', 0), System::getEnv('_APP_COMPUTE_MEMORY', 0), 'buildSpecifications' - ), 'Build specification for the site deployments.', true, ['plan']) + )), 'Build specification for the site deployments.', true, ['plan']) ->param('runtimeSpecification', fn (array $plan) => $this->getDefaultSpecification($plan), fn (array $plan) => new Specification( $plan, Config::getParam('specifications', []), @@ -134,7 +134,7 @@ class Update extends Base string $providerRootDirectory, ?array $providerBranches, ?array $providerPaths, - string $buildSpecification, + ?string $buildSpecification, string $runtimeSpecification, int $deploymentRetention, Request $request, @@ -178,6 +178,8 @@ class Update extends Base $framework = $site->getAttribute('framework'); } + $buildSpecification ??= $site->getAttribute('buildSpecification', APP_SITES_BUILD_SPECIFICATION_DEFAULT); + $repositoryId = $site->getAttribute('repositoryId', ''); $repositoryInternalId = $site->getAttribute('repositoryInternalId', ''); diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index 436afea1bd..7a5f578492 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -1703,6 +1703,23 @@ final class SitesCustomServerTest extends Scope $this->assertEquals($buildSpecification, $site['body']['buildSpecification']); $this->assertEquals(Specification::S_1VCPU_1GB, $site['body']['runtimeSpecification']); + $site = $this->updateSite([ + 'buildRuntime' => 'node-22', + 'fallbackFile' => '', + 'framework' => 'other', + 'name' => 'Test Site', + 'outputDirectory' => './', + 'providerBranch' => 'main', + 'providerRootDirectory' => './', + '$id' => $siteId, + 'runtimeSpecification' => Specification::S_1VCPU_1GB, + ]); + + $this->assertEquals(200, $site['headers']['status-code']); + $this->assertNotEmpty($site['body']['$id']); + $this->assertEquals($buildSpecification, $site['body']['buildSpecification']); + $this->assertEquals(Specification::S_1VCPU_1GB, $site['body']['runtimeSpecification']); + // Change the specs to 1vcpu 512mb $site = $this->updateSite([ 'buildRuntime' => 'node-22', From bcb0cb014fe1165faa6f71e0ecce49693d324f22 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Tue, 23 Jun 2026 15:04:59 +0400 Subject: [PATCH 10/13] Preserve legacy build specification limits --- .../Platform/Modules/Compute/Base.php | 1 + .../Compute/Validator/Specification.php | 14 +++++++++-- .../Functions/Http/Specifications/XList.php | 3 ++- .../Sites/Http/Specifications/XList.php | 3 ++- .../Compute/Validator/SpecificationTest.php | 23 +++++++++++++++++++ 5 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Compute/Base.php b/src/Appwrite/Platform/Modules/Compute/Base.php index b3740787b3..07e09a3b89 100644 --- a/src/Appwrite/Platform/Modules/Compute/Base.php +++ b/src/Appwrite/Platform/Modules/Compute/Base.php @@ -49,6 +49,7 @@ class Base extends Action $planKey ); $allowedSpecifications = $specificationValidator->getAllowedSpecifications(); + $planKey = $specificationValidator->getPlanKey(); if (empty($allowedSpecifications)) { return $fallback; diff --git a/src/Appwrite/Platform/Modules/Compute/Validator/Specification.php b/src/Appwrite/Platform/Modules/Compute/Validator/Specification.php index 5f1337c97f..8a77afef24 100644 --- a/src/Appwrite/Platform/Modules/Compute/Validator/Specification.php +++ b/src/Appwrite/Platform/Modules/Compute/Validator/Specification.php @@ -25,6 +25,15 @@ class Specification extends Validator $this->planKey = $planKey; } + public function getPlanKey(): string + { + if ($this->planKey === 'buildSpecifications' && !array_key_exists('buildSpecifications', $this->plan) && array_key_exists('runtimeSpecifications', $this->plan)) { + return 'runtimeSpecifications'; + } + + return $this->planKey; + } + /** * Get Allowed Specifications. * @@ -35,11 +44,12 @@ class Specification extends Validator public function getAllowedSpecifications(): array { $allowedSpecifications = []; + $planKey = $this->getPlanKey(); foreach ($this->specifications as $size => $values) { if ((empty($this->maxCpus) || $values['cpus'] <= $this->maxCpus) && (empty($this->maxMemory) || $values['memory'] <= $this->maxMemory)) { - if (!empty($this->plan) && array_key_exists($this->planKey, $this->plan)) { - if (!\in_array($size, $this->plan[$this->planKey])) { + if (!empty($this->plan) && array_key_exists($planKey, $this->plan)) { + if (!\in_array($size, $this->plan[$planKey])) { continue; } } diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Specifications/XList.php b/src/Appwrite/Platform/Modules/Functions/Http/Specifications/XList.php index 8cbff906fa..e8177abdbd 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Specifications/XList.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Specifications/XList.php @@ -3,6 +3,7 @@ namespace Appwrite\Platform\Modules\Functions\Http\Specifications; use Appwrite\Platform\Modules\Compute\Base; +use Appwrite\Platform\Modules\Compute\Validator\Specification; use Appwrite\SDK\AuthType; use Appwrite\SDK\Method; use Appwrite\SDK\Response as SDKResponse; @@ -56,7 +57,7 @@ class XList extends Base public function action(string $type, Response $response, array $plan) { $allSpecs = Config::getParam('specifications', []); - $planKey = $type === 'builds' ? 'buildSpecifications' : 'runtimeSpecifications'; + $planKey = (new Specification($plan, [], 0, 0, $type === 'builds' ? 'buildSpecifications' : 'runtimeSpecifications'))->getPlanKey(); $specs = []; foreach ($allSpecs as $spec) { diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Specifications/XList.php b/src/Appwrite/Platform/Modules/Sites/Http/Specifications/XList.php index a4f865d859..735e45bcdc 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Specifications/XList.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Specifications/XList.php @@ -3,6 +3,7 @@ namespace Appwrite\Platform\Modules\Sites\Http\Specifications; use Appwrite\Platform\Modules\Compute\Base; +use Appwrite\Platform\Modules\Compute\Validator\Specification; use Appwrite\SDK\AuthType; use Appwrite\SDK\Method; use Appwrite\SDK\Response as SDKResponse; @@ -56,7 +57,7 @@ class XList extends Base public function action(string $type, Response $response, array $plan) { $allSpecs = Config::getParam('specifications', []); - $planKey = $type === 'builds' ? 'buildSpecifications' : 'runtimeSpecifications'; + $planKey = (new Specification($plan, [], 0, 0, $type === 'builds' ? 'buildSpecifications' : 'runtimeSpecifications'))->getPlanKey(); $specs = []; foreach ($allSpecs as $spec) { diff --git a/tests/unit/Platform/Modules/Compute/Validator/SpecificationTest.php b/tests/unit/Platform/Modules/Compute/Validator/SpecificationTest.php index abc6296d0a..15d9961aa8 100644 --- a/tests/unit/Platform/Modules/Compute/Validator/SpecificationTest.php +++ b/tests/unit/Platform/Modules/Compute/Validator/SpecificationTest.php @@ -96,4 +96,27 @@ final class SpecificationTest extends TestCase $this->assertContains(SpecificationConstants::S_1VCPU_1GB, $allowed); $this->assertContains(SpecificationConstants::S_2VCPU_2GB, $allowed); } + + public function testGetAllowedSpecificationsWithLegacyBuildPlanLimits(): void + { + $plan = [ + 'runtimeSpecifications' => [ + SpecificationConstants::S_05VCPU_512MB, + SpecificationConstants::S_1VCPU_512MB, + ] + ]; + $validator = new Specification( + plan: $plan, + specifications: $this->specifications, + maxCpus: 0, + maxMemory: 0, + planKey: 'buildSpecifications' + ); + + $allowed = $validator->getAllowedSpecifications(); + $this->assertEquals('runtimeSpecifications', $validator->getPlanKey()); + $this->assertCount(2, $allowed); + $this->assertContains(SpecificationConstants::S_05VCPU_512MB, $allowed); + $this->assertContains(SpecificationConstants::S_1VCPU_512MB, $allowed); + } } From c44c5e6733792b6988c663d32340fdb6ad65a87c Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Tue, 23 Jun 2026 15:18:32 +0400 Subject: [PATCH 11/13] Apply specification test rector fix --- .../Platform/Modules/Compute/Validator/SpecificationTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/Platform/Modules/Compute/Validator/SpecificationTest.php b/tests/unit/Platform/Modules/Compute/Validator/SpecificationTest.php index 15d9961aa8..5b9c8b4310 100644 --- a/tests/unit/Platform/Modules/Compute/Validator/SpecificationTest.php +++ b/tests/unit/Platform/Modules/Compute/Validator/SpecificationTest.php @@ -114,7 +114,7 @@ final class SpecificationTest extends TestCase ); $allowed = $validator->getAllowedSpecifications(); - $this->assertEquals('runtimeSpecifications', $validator->getPlanKey()); + $this->assertSame('runtimeSpecifications', $validator->getPlanKey()); $this->assertCount(2, $allowed); $this->assertContains(SpecificationConstants::S_05VCPU_512MB, $allowed); $this->assertContains(SpecificationConstants::S_1VCPU_512MB, $allowed); From 38467157db2c175cfbc2b00de587736f18b3d0c9 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Tue, 23 Jun 2026 15:26:58 +0400 Subject: [PATCH 12/13] Revert "Apply specification test rector fix" This reverts commit c44c5e6733792b6988c663d32340fdb6ad65a87c. --- .../Platform/Modules/Compute/Validator/SpecificationTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/Platform/Modules/Compute/Validator/SpecificationTest.php b/tests/unit/Platform/Modules/Compute/Validator/SpecificationTest.php index 5b9c8b4310..15d9961aa8 100644 --- a/tests/unit/Platform/Modules/Compute/Validator/SpecificationTest.php +++ b/tests/unit/Platform/Modules/Compute/Validator/SpecificationTest.php @@ -114,7 +114,7 @@ final class SpecificationTest extends TestCase ); $allowed = $validator->getAllowedSpecifications(); - $this->assertSame('runtimeSpecifications', $validator->getPlanKey()); + $this->assertEquals('runtimeSpecifications', $validator->getPlanKey()); $this->assertCount(2, $allowed); $this->assertContains(SpecificationConstants::S_05VCPU_512MB, $allowed); $this->assertContains(SpecificationConstants::S_1VCPU_512MB, $allowed); From e9baaddfaddedda7072c9651d12f3f2f49d2c5b7 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Tue, 23 Jun 2026 15:26:58 +0400 Subject: [PATCH 13/13] Revert "Preserve legacy build specification limits" This reverts commit bcb0cb014fe1165faa6f71e0ecce49693d324f22. --- .../Platform/Modules/Compute/Base.php | 1 - .../Compute/Validator/Specification.php | 14 ++--------- .../Functions/Http/Specifications/XList.php | 3 +-- .../Sites/Http/Specifications/XList.php | 3 +-- .../Compute/Validator/SpecificationTest.php | 23 ------------------- 5 files changed, 4 insertions(+), 40 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Compute/Base.php b/src/Appwrite/Platform/Modules/Compute/Base.php index 07e09a3b89..b3740787b3 100644 --- a/src/Appwrite/Platform/Modules/Compute/Base.php +++ b/src/Appwrite/Platform/Modules/Compute/Base.php @@ -49,7 +49,6 @@ class Base extends Action $planKey ); $allowedSpecifications = $specificationValidator->getAllowedSpecifications(); - $planKey = $specificationValidator->getPlanKey(); if (empty($allowedSpecifications)) { return $fallback; diff --git a/src/Appwrite/Platform/Modules/Compute/Validator/Specification.php b/src/Appwrite/Platform/Modules/Compute/Validator/Specification.php index 8a77afef24..5f1337c97f 100644 --- a/src/Appwrite/Platform/Modules/Compute/Validator/Specification.php +++ b/src/Appwrite/Platform/Modules/Compute/Validator/Specification.php @@ -25,15 +25,6 @@ class Specification extends Validator $this->planKey = $planKey; } - public function getPlanKey(): string - { - if ($this->planKey === 'buildSpecifications' && !array_key_exists('buildSpecifications', $this->plan) && array_key_exists('runtimeSpecifications', $this->plan)) { - return 'runtimeSpecifications'; - } - - return $this->planKey; - } - /** * Get Allowed Specifications. * @@ -44,12 +35,11 @@ class Specification extends Validator public function getAllowedSpecifications(): array { $allowedSpecifications = []; - $planKey = $this->getPlanKey(); foreach ($this->specifications as $size => $values) { if ((empty($this->maxCpus) || $values['cpus'] <= $this->maxCpus) && (empty($this->maxMemory) || $values['memory'] <= $this->maxMemory)) { - if (!empty($this->plan) && array_key_exists($planKey, $this->plan)) { - if (!\in_array($size, $this->plan[$planKey])) { + if (!empty($this->plan) && array_key_exists($this->planKey, $this->plan)) { + if (!\in_array($size, $this->plan[$this->planKey])) { continue; } } diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Specifications/XList.php b/src/Appwrite/Platform/Modules/Functions/Http/Specifications/XList.php index e8177abdbd..8cbff906fa 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Specifications/XList.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Specifications/XList.php @@ -3,7 +3,6 @@ namespace Appwrite\Platform\Modules\Functions\Http\Specifications; use Appwrite\Platform\Modules\Compute\Base; -use Appwrite\Platform\Modules\Compute\Validator\Specification; use Appwrite\SDK\AuthType; use Appwrite\SDK\Method; use Appwrite\SDK\Response as SDKResponse; @@ -57,7 +56,7 @@ class XList extends Base public function action(string $type, Response $response, array $plan) { $allSpecs = Config::getParam('specifications', []); - $planKey = (new Specification($plan, [], 0, 0, $type === 'builds' ? 'buildSpecifications' : 'runtimeSpecifications'))->getPlanKey(); + $planKey = $type === 'builds' ? 'buildSpecifications' : 'runtimeSpecifications'; $specs = []; foreach ($allSpecs as $spec) { diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Specifications/XList.php b/src/Appwrite/Platform/Modules/Sites/Http/Specifications/XList.php index 735e45bcdc..a4f865d859 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Specifications/XList.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Specifications/XList.php @@ -3,7 +3,6 @@ namespace Appwrite\Platform\Modules\Sites\Http\Specifications; use Appwrite\Platform\Modules\Compute\Base; -use Appwrite\Platform\Modules\Compute\Validator\Specification; use Appwrite\SDK\AuthType; use Appwrite\SDK\Method; use Appwrite\SDK\Response as SDKResponse; @@ -57,7 +56,7 @@ class XList extends Base public function action(string $type, Response $response, array $plan) { $allSpecs = Config::getParam('specifications', []); - $planKey = (new Specification($plan, [], 0, 0, $type === 'builds' ? 'buildSpecifications' : 'runtimeSpecifications'))->getPlanKey(); + $planKey = $type === 'builds' ? 'buildSpecifications' : 'runtimeSpecifications'; $specs = []; foreach ($allSpecs as $spec) { diff --git a/tests/unit/Platform/Modules/Compute/Validator/SpecificationTest.php b/tests/unit/Platform/Modules/Compute/Validator/SpecificationTest.php index 15d9961aa8..abc6296d0a 100644 --- a/tests/unit/Platform/Modules/Compute/Validator/SpecificationTest.php +++ b/tests/unit/Platform/Modules/Compute/Validator/SpecificationTest.php @@ -96,27 +96,4 @@ final class SpecificationTest extends TestCase $this->assertContains(SpecificationConstants::S_1VCPU_1GB, $allowed); $this->assertContains(SpecificationConstants::S_2VCPU_2GB, $allowed); } - - public function testGetAllowedSpecificationsWithLegacyBuildPlanLimits(): void - { - $plan = [ - 'runtimeSpecifications' => [ - SpecificationConstants::S_05VCPU_512MB, - SpecificationConstants::S_1VCPU_512MB, - ] - ]; - $validator = new Specification( - plan: $plan, - specifications: $this->specifications, - maxCpus: 0, - maxMemory: 0, - planKey: 'buildSpecifications' - ); - - $allowed = $validator->getAllowedSpecifications(); - $this->assertEquals('runtimeSpecifications', $validator->getPlanKey()); - $this->assertCount(2, $allowed); - $this->assertContains(SpecificationConstants::S_05VCPU_512MB, $allowed); - $this->assertContains(SpecificationConstants::S_1VCPU_512MB, $allowed); - } }