From ec191af874b85f76ac92994caa8b297d22cf7964 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 18 Jul 2024 14:23:15 +0200 Subject: [PATCH] chore: Handle JSON parsing errors in format_docker_command_output_to_json --- bootstrap/helpers/docker.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bootstrap/helpers/docker.php b/bootstrap/helpers/docker.php index 21e946a9a..0aa5c6b74 100644 --- a/bootstrap/helpers/docker.php +++ b/bootstrap/helpers/docker.php @@ -48,9 +48,13 @@ function format_docker_command_output_to_json($rawOutput): Collection $outputLines = collect($outputLines); } - return $outputLines - ->reject(fn ($line) => empty($line)) - ->map(fn ($outputLine) => json_decode($outputLine, true, flags: JSON_THROW_ON_ERROR)); + try { + return $outputLines + ->reject(fn ($line) => empty($line)) + ->map(fn ($outputLine) => json_decode($outputLine, true, flags: JSON_THROW_ON_ERROR)); + } catch (\Throwable $e) { + return collect([]); + } } function format_docker_labels_to_json(string|array $rawOutput): Collection