diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index a36dfe1e4c..66d97c61b2 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -1753,9 +1753,6 @@ App::post('/v1/functions/:functionId/executions') Console::error($th->getMessage()); if ($th instanceof AppwriteException) { - if ($function->getAttribute('logging')) { - Authorization::skip(fn () => $dbForProject->createDocument('executions', $execution)); - } throw $th; } } finally { @@ -1765,11 +1762,11 @@ App::post('/v1/functions/:functionId/executions') ->addMetric(METRIC_EXECUTIONS_COMPUTE, (int)($execution->getAttribute('duration') * 1000)) // per project ->addMetric(str_replace('{functionInternalId}', $function->getInternalId(), METRIC_FUNCTION_ID_EXECUTIONS_COMPUTE), (int)($execution->getAttribute('duration') * 1000)) // per function ; - } - if ($function->getAttribute('logging')) { - /** @var Document $execution */ - $execution = Authorization::skip(fn () => $dbForProject->createDocument('executions', $execution)); + if ($function->getAttribute('logging')) { + /** @var Document $execution */ + $execution = Authorization::skip(fn () => $dbForProject->createDocument('executions', $execution)); + } } $roles = Authorization::getRoles(); diff --git a/app/controllers/general.php b/app/controllers/general.php index cb115c3721..0fd7e7e4c3 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -300,9 +300,6 @@ function router(App $utopia, Database $dbForConsole, callable $getProjectDB, Swo Console::error($th->getMessage()); if ($th instanceof AppwriteException) { - if ($function->getAttribute('logging')) { - Authorization::skip(fn () => $dbForProject->createDocument('executions', $execution)); - } throw $th; } } finally { @@ -312,11 +309,11 @@ function router(App $utopia, Database $dbForConsole, callable $getProjectDB, Swo ->addMetric(METRIC_EXECUTIONS_COMPUTE, (int)($execution->getAttribute('duration') * 1000)) // per project ->addMetric(str_replace('{functionInternalId}', $function->getInternalId(), METRIC_FUNCTION_ID_EXECUTIONS_COMPUTE), (int)($execution->getAttribute('duration') * 1000)) // per function ; - } - if ($function->getAttribute('logging')) { - /** @var Document $execution */ - $execution = Authorization::skip(fn () => $dbForProject->createDocument('executions', $execution)); + if ($function->getAttribute('logging')) { + /** @var Document $execution */ + $execution = Authorization::skip(fn () => $dbForProject->createDocument('executions', $execution)); + } } $execution->setAttribute('logs', '');