Update app/controllers/general.php

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
Jake Barnby
2025-08-22 19:24:01 +12:00
committed by GitHub
parent 45e31f2b1c
commit 355fd47c62
+4 -5
View File
@@ -624,8 +624,8 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw
if (\is_string($logs) && \strlen($logs) > $maxLogLength) {
$warningMessage = "[WARNING] Logs truncated. The output exceeded {$maxLogLength} characters.\n";
$warningLength = \strlen($warningMessage);
$maxContentLength = $maxLogLength - $warningLength;
$logs = $warningMessage . \substr($logs, -$maxContentLength);
$maxContentLength = max(0, $maxLogLength - $warningLength);
$logs = $warningMessage . ($maxContentLength > 0 ? \substr($logs, -$maxContentLength) : '');
}
// Truncate errors if they exceed the limit
@@ -635,10 +635,9 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw
if (\is_string($errors) && \strlen($errors) > $maxErrorLength) {
$warningMessage = "[WARNING] Errors truncated. The output exceeded {$maxErrorLength} characters.\n";
$warningLength = \strlen($warningMessage);
$maxContentLength = $maxErrorLength - $warningLength;
$errors = $warningMessage . \substr($errors, -$maxContentLength);
$maxContentLength = max(0, $maxErrorLength - $warningLength);
$errors = $warningMessage . ($maxContentLength > 0 ? \substr($errors, -$maxContentLength) : '');
}
/** Update execution status */
$status = $executionResponse['statusCode'] >= 500 ? 'failed' : 'completed';
$execution->setAttribute('status', $status);