From a609759951bf696e2808ddccfcba5a82a8de7fc9 Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Sat, 2 Sep 2023 16:37:40 -0700 Subject: [PATCH] Make runtime optional when updating a function This is important for backwards compatibility since it wasn't possible to update a function runtime in previous versions and it was never included in the request. --- app/controllers/api/functions.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index d3d1cb2509..bbdd12c85f 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -660,7 +660,7 @@ App::put('/v1/functions/:functionId') ->label('sdk.response.model', Response::MODEL_FUNCTION) ->param('functionId', '', new UID(), 'Function ID.') ->param('name', '', new Text(128), 'Function name. Max length: 128 chars.') - ->param('runtime', '', new WhiteList(array_keys(Config::getParam('runtimes')), true), 'Execution runtime.') + ->param('runtime', '', new WhiteList(array_keys(Config::getParam('runtimes')), true), 'Execution runtime.', true) ->param('execute', [], new Roles(APP_LIMIT_ARRAY_PARAMS_SIZE), 'An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' roles are allowed, each 64 characters long.', true) ->param('events', [], new ArrayList(new ValidatorEvent(), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Events list. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' events are allowed.', true) ->param('schedule', '', new Cron(), 'Schedule CRON syntax.', true) @@ -704,6 +704,10 @@ App::put('/v1/functions/:functionId') throw new Exception(Exception::FUNCTION_NOT_FOUND); } + if (empty($runtime)) { + $runtime = $function->getAttribute('runtime'); + } + $enabled ??= $function->getAttribute('enabled', true); $repositoryId = $function->getAttribute('repositoryId', '');