diff --git a/app/config/collections.php b/app/config/collections.php
index 7e63636108..2f630e0ba1 100644
--- a/app/config/collections.php
+++ b/app/config/collections.php
@@ -1377,6 +1377,15 @@ $collections = [
'required' => false,
'array' => false,
],
+ [
+ '$collection' => Database::SYSTEM_COLLECTION_RULES,
+ 'label' => 'Tag ID',
+ 'key' => 'tagId',
+ 'type' => Database::SYSTEM_VAR_TYPE_KEY,
+ 'default' => '',
+ 'required' => false,
+ 'array' => false,
+ ],
[
'$collection' => Database::SYSTEM_COLLECTION_RULES,
'label' => 'Status',
diff --git a/app/views/console/functions/function.phtml b/app/views/console/functions/function.phtml
index 12b5605893..be0b9c4d87 100644
--- a/app/views/console/functions/function.phtml
+++ b/app/views/console/functions/function.phtml
@@ -68,8 +68,6 @@ $events = array_keys($this->getParam('events', []));
-
Tags
-
getParam('events', []));
data-success="trigger"
data-success-param-trigger-events="functions.listTags">
+
Tags
+
No Tags Found
diff --git a/app/workers/functions.php b/app/workers/functions.php
index 3916ffbd7f..6730068676 100644
--- a/app/workers/functions.php
+++ b/app/workers/functions.php
@@ -184,6 +184,7 @@ class FunctionsV1
$tagPathTarget = '/tmp/project-'.$projectId.'/'.$tag->getId().'/code.tar.gz';
$tagPathTargetDir = \pathinfo($tagPathTarget, PATHINFO_DIRNAME);
$container = 'appwrite-function-'.$tag->getId();
+ $command = escapeshellcmd($tag->getAttribute('command', ''));
if(!\is_readable($tagPath)) {
throw new Exception('Code is not readable: '.$tag->getAttribute('codePath', ''));
@@ -295,7 +296,7 @@ class FunctionsV1
$executionStart = \microtime(true);
- $exitCode = Console::execute("docker exec {$container} sh -c '{$tag->getAttribute('command', '')}'"
+ $exitCode = Console::execute("docker exec {$container} {$command}"
, null, $stdout, $stderr, $function->getAttribute('timeout', 900)); // TODO add app env for max timeout
$executionEnd = \microtime(true);
@@ -305,10 +306,11 @@ class FunctionsV1
Authorization::disable();
$execution = $projectDB->updateDocument(array_merge($execution->getArrayCopy(), [
+ 'tagId' => $tag->getId(),
'status' => ($exitCode === 0) ? 'completed' : 'failed',
'exitCode' => $exitCode,
- 'stdout' => mb_substr($stdout, -2000), // log last 2000 chars output
- 'stderr' => mb_substr($stderr, -2000), // log last 2000 chars output
+ 'stdout' => mb_substr($stdout, -4000), // log last 4000 chars output
+ 'stderr' => mb_substr($stderr, -4000), // log last 4000 chars output
'time' => ($executionEnd - $executionStart),
]));