diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 18fa6b822b..69f7f40872 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -431,13 +431,13 @@ App::get('/v1/functions/runtimes') $allowList = \array_filter(\explode(',', System::getEnv('_APP_FUNCTIONS_RUNTIMES', ''))); $allowed = []; - foreach ($runtimes as $key => $runtime) { - if (!empty($allowList) && !\in_array($key, $allowList)) { + foreach ($runtimes as $id => $runtime) { + if (!empty($allowList) && !\in_array($id, $allowList)) { continue; } - $runtimes[$key]['$id'] = $key; - $allowed[] = $runtimes[$key]; + $runtime['$id'] = $id; + $allowed[] = $runtime; } $response->dynamic(new Document([ diff --git a/src/Appwrite/Utopia/Response/Model/Runtime.php b/src/Appwrite/Utopia/Response/Model/Runtime.php index 8bc42cb418..3c328c4d40 100644 --- a/src/Appwrite/Utopia/Response/Model/Runtime.php +++ b/src/Appwrite/Utopia/Response/Model/Runtime.php @@ -16,6 +16,12 @@ class Runtime extends Model 'default' => '', 'example' => 'python-3.8', ]) + ->addRule('key', [ + 'type' => self::TYPE_STRING, + 'description' => 'Parent runtime key.', + 'default' => '', + 'example' => 'python', + ]) ->addRule('name', [ 'type' => self::TYPE_STRING, 'description' => 'Runtime Name.', diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 7fc9810b85..5408d0f718 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -1429,6 +1429,7 @@ class FunctionsCustomServerTest extends Scope $this->assertArrayHasKey('$id', $runtime); $this->assertArrayHasKey('name', $runtime); + $this->assertArrayHasKey('key', $runtime); $this->assertArrayHasKey('version', $runtime); $this->assertArrayHasKey('logo', $runtime); $this->assertArrayHasKey('image', $runtime);