From c2e4bc2ae3901d040dd2d942ed74ac082e0f10f2 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Mon, 4 May 2026 07:27:27 +0100 Subject: [PATCH] Simplify sanitizeErrors now that jsonSerialize doesn't emit trace With Migration\Exception::jsonSerialize() no longer including the stack trace, sanitizeErrors no longer needs to decode/strip/re-encode each entry. Reduce it to a single json_encode pass. --- src/Appwrite/Platform/Workers/Migrations.php | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Migrations.php b/src/Appwrite/Platform/Workers/Migrations.php index 63956bc90d..03578b4ddc 100644 --- a/src/Appwrite/Platform/Workers/Migrations.php +++ b/src/Appwrite/Platform/Workers/Migrations.php @@ -857,7 +857,7 @@ class Migrations extends Action } /** - * Sanitize migration errors, removing sensitive information like stack traces + * Encode migration errors as JSON strings for storage on the migration document. * * @param array $sourceErrors * @param array $destinationErrors @@ -867,20 +867,10 @@ class Migrations extends Action array $sourceErrors, array $destinationErrors, ): array { - $errors = []; - foreach ([...$sourceErrors, ...$destinationErrors] as $error) { - $encoded = \json_decode(\json_encode($error), true); - if (\is_array($encoded)) { - if (isset($encoded['trace'])) { - unset($encoded['trace']); - } - $errors[] = \json_encode($encoded); - } else { - $errors[] = \json_encode($error); - } - } - - return $errors; + return \array_map( + fn ($error) => \json_encode($error), + [...$sourceErrors, ...$destinationErrors], + ); } private function processMigrationResourceStats(array $resources, Context $usage, Document $projectDocument, UsagePublisher $publisherForUsage, string $source, Authorization $authorization, ?string $resourceId)