From 3665c4766ec0dcb0cae2f105da6b90611093e0c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Thu, 12 Sep 2024 13:07:17 +0000 Subject: [PATCH 1/6] Update structure of logs --- app/http.php | 24 +++++++++++++++++------- composer.lock | 12 ++++++------ 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/app/http.php b/app/http.php index a3df530..d85c0ae 100644 --- a/app/http.php +++ b/app/http.php @@ -1214,6 +1214,12 @@ function (string $runtimeId, ?string $payload, string $path, string $method, arr ->action(function (?Route $route, Throwable $error, ?Logger $logger, Response $response, Log $log) { logError($log, $error, "httpError", $logger, $route); + $version = System::getEnv('OPR_EXECUTOR_VERSION', 'UNKNOWN'); + $message = $error->getMessage(); + $file = $error->getFile(); + $line = $error->getLine(); + $trace = $error->getTrace(); + switch ($error->getCode()) { case 400: // Error allowed publicly case 401: // Error allowed publicly @@ -1233,13 +1239,17 @@ function (string $runtimeId, ?string $payload, string $path, string $method, arr $code = 500; // All other errors get the generic 500 server error status code } - $output = [ - 'message' => $error->getMessage(), - 'code' => $error->getCode(), - 'file' => $error->getFile(), - 'line' => $error->getLine(), - 'trace' => $error->getTrace(), - 'version' => Http::getEnv('OPR_EXECUTOR_VERSION', 'UNKNOWN') + $output = ((Http::isDevelopment())) ? [ + 'message' => $message, + 'code' => $code, + 'file' => $file, + 'line' => $line, + 'trace' => \json_encode($trace, JSON_UNESCAPED_UNICODE) === false ? [] : $trace, // check for failing encode + 'version' => $version + ] : [ + 'message' => $message, + 'code' => $code, + 'version' => $version ]; $response diff --git a/composer.lock b/composer.lock index 020058e..8fc13fc 100644 --- a/composer.lock +++ b/composer.lock @@ -416,16 +416,16 @@ }, { "name": "utopia-php/storage", - "version": "0.18.4", + "version": "0.18.5", "source": { "type": "git", "url": "https://github.com/utopia-php/storage.git", - "reference": "94ab8758fabcefee5c5fa723616e45719833f922" + "reference": "7d355c5e3ccc8ecebc0266f8ddd30088a43be919" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/storage/zipball/94ab8758fabcefee5c5fa723616e45719833f922", - "reference": "94ab8758fabcefee5c5fa723616e45719833f922", + "url": "https://api.github.com/repos/utopia-php/storage/zipball/7d355c5e3ccc8ecebc0266f8ddd30088a43be919", + "reference": "7d355c5e3ccc8ecebc0266f8ddd30088a43be919", "shasum": "" }, "require": { @@ -465,9 +465,9 @@ ], "support": { "issues": "https://github.com/utopia-php/storage/issues", - "source": "https://github.com/utopia-php/storage/tree/0.18.4" + "source": "https://github.com/utopia-php/storage/tree/0.18.5" }, - "time": "2024-04-02T08:24:09+00:00" + "time": "2024-09-04T08:57:27+00:00" }, { "name": "utopia-php/system", From 5dcd8c9afebbc2f5a32167519cd326eb685d69ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Thu, 12 Sep 2024 13:11:33 +0000 Subject: [PATCH 2/6] Revert version changes --- composer.json | 2 +- composer.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 0276f9b..b829061 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "utopia-php/framework": "0.34.*", "utopia-php/logger": "0.5.*", "utopia-php/cli": "0.16.*", - "utopia-php/storage": "0.18.*", + "utopia-php/storage": "0.18.4", "utopia-php/dsn": "0.1.*", "utopia-php/registry": "0.5.*", "utopia-php/preloader": "0.2.*", diff --git a/composer.lock b/composer.lock index 8fc13fc..ea515d9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d3407e94419a76cd7c6d6a98c99dedad", + "content-hash": "19fe70910a8bd439efe6aa78329b7a7f", "packages": [ { "name": "appwrite/php-runtimes", @@ -416,16 +416,16 @@ }, { "name": "utopia-php/storage", - "version": "0.18.5", + "version": "0.18.4", "source": { "type": "git", "url": "https://github.com/utopia-php/storage.git", - "reference": "7d355c5e3ccc8ecebc0266f8ddd30088a43be919" + "reference": "94ab8758fabcefee5c5fa723616e45719833f922" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/storage/zipball/7d355c5e3ccc8ecebc0266f8ddd30088a43be919", - "reference": "7d355c5e3ccc8ecebc0266f8ddd30088a43be919", + "url": "https://api.github.com/repos/utopia-php/storage/zipball/94ab8758fabcefee5c5fa723616e45719833f922", + "reference": "94ab8758fabcefee5c5fa723616e45719833f922", "shasum": "" }, "require": { @@ -465,9 +465,9 @@ ], "support": { "issues": "https://github.com/utopia-php/storage/issues", - "source": "https://github.com/utopia-php/storage/tree/0.18.5" + "source": "https://github.com/utopia-php/storage/tree/0.18.4" }, - "time": "2024-09-04T08:57:27+00:00" + "time": "2024-04-02T08:24:09+00:00" }, { "name": "utopia-php/system", From ad508eba257eaf04b39f2d742f62d103800f47e8 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Fri, 13 Sep 2024 12:40:20 +0000 Subject: [PATCH 3/6] chore: revert composer --- composer.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.lock b/composer.lock index ea515d9..020058e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "19fe70910a8bd439efe6aa78329b7a7f", + "content-hash": "d3407e94419a76cd7c6d6a98c99dedad", "packages": [ { "name": "appwrite/php-runtimes", From 994d99fc65d9d1525312997d1e1222cc9a6429a4 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Fri, 13 Sep 2024 12:41:28 +0000 Subject: [PATCH 4/6] chore: revert composer --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b829061..0276f9b 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "utopia-php/framework": "0.34.*", "utopia-php/logger": "0.5.*", "utopia-php/cli": "0.16.*", - "utopia-php/storage": "0.18.4", + "utopia-php/storage": "0.18.*", "utopia-php/dsn": "0.1.*", "utopia-php/registry": "0.5.*", "utopia-php/preloader": "0.2.*", From 5cc8b0b990db91e58a585a1066ce6f1c82a825c9 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Fri, 13 Sep 2024 12:45:05 +0000 Subject: [PATCH 5/6] fix: update imports --- app/http.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/http.php b/app/http.php index d85c0ae..38b8b1c 100644 --- a/app/http.php +++ b/app/http.php @@ -1214,7 +1214,7 @@ function (string $runtimeId, ?string $payload, string $path, string $method, arr ->action(function (?Route $route, Throwable $error, ?Logger $logger, Response $response, Log $log) { logError($log, $error, "httpError", $logger, $route); - $version = System::getEnv('OPR_EXECUTOR_VERSION', 'UNKNOWN'); + $version = Http::getEnv('OPR_EXECUTOR_VERSION', 'UNKNOWN'); $message = $error->getMessage(); $file = $error->getFile(); $line = $error->getLine(); From 0adc420dbd83bfde7c17bf9b4c97a1ad0b0fd0ff Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Fri, 13 Sep 2024 13:28:16 +0000 Subject: [PATCH 6/6] fix: review comments --- app/http.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/http.php b/app/http.php index 38b8b1c..03fdbb9 100644 --- a/app/http.php +++ b/app/http.php @@ -1239,7 +1239,7 @@ function (string $runtimeId, ?string $payload, string $path, string $method, arr $code = 500; // All other errors get the generic 500 server error status code } - $output = ((Http::isDevelopment())) ? [ + $output = Http::isDevelopment() ? [ 'message' => $message, 'code' => $code, 'file' => $file,