Skip to content

Commit ec191af

Browse files
committed
chore: Handle JSON parsing errors in format_docker_command_output_to_json
1 parent d98c742 commit ec191af

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

bootstrap/helpers/docker.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,13 @@ function format_docker_command_output_to_json($rawOutput): Collection
4848
$outputLines = collect($outputLines);
4949
}
5050

51-
return $outputLines
52-
->reject(fn ($line) => empty($line))
53-
->map(fn ($outputLine) => json_decode($outputLine, true, flags: JSON_THROW_ON_ERROR));
51+
try {
52+
return $outputLines
53+
->reject(fn ($line) => empty($line))
54+
->map(fn ($outputLine) => json_decode($outputLine, true, flags: JSON_THROW_ON_ERROR));
55+
} catch (\Throwable $e) {
56+
return collect([]);
57+
}
5458
}
5559

5660
function format_docker_labels_to_json(string|array $rawOutput): Collection

0 commit comments

Comments
 (0)