Skip to content

Commit bf2456d

Browse files
committed
Ensure eggs endpoint always returns an object, even when empty
closes pterodactyl#4296
1 parent b050174 commit bf2456d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

app/Transformers/Api/Application/EggTransformer.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ public function getResourceName(): string
3838
*/
3939
public function transform(Egg $model)
4040
{
41+
$files = json_decode($model->config_files, true, 512, JSON_THROW_ON_ERROR);
42+
if (empty($files)) {
43+
$files = new \stdClass();
44+
}
45+
4146
return [
4247
'id' => $model->id,
4348
'uuid' => $model->uuid,
@@ -51,7 +56,7 @@ public function transform(Egg $model)
5156
'docker_image' => count($model->docker_images) > 0 ? Arr::first($model->docker_images) : '',
5257
'docker_images' => $model->docker_images,
5358
'config' => [
54-
'files' => json_decode($model->config_files, true),
59+
'files' => $files,
5560
'startup' => json_decode($model->config_startup, true),
5661
'stop' => $model->config_stop,
5762
'logs' => json_decode($model->config_logs, true),

0 commit comments

Comments
 (0)