fix: handle null ports in Docker container table (#5313)

When Docker API returns `null` for container ports (instead of `[]`),
the Docker management page crashes. Added optional chaining on
`ports?.length` to handle this case.

Fixes #5311

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
This commit is contained in:
Matt Van HornandMatt Van Horn authored and GitHub committed 2026-03-27 20:04:03 +01:00
1 parent d53c922688
commit 1639da5779
4 files changed
+5 -3

No files matched your search

+2 -1
View File
@@ -1,5 +1,6 @@
import dayjs from "dayjs";
import type { ContainerInfo, ContainerStats } from "dockerode";
import type Dockerode from "dockerode";
import { db, like, or } from "@homarr/db";
import { icons } from "@homarr/db/schema";
@@ -72,7 +73,7 @@ async function getContainersWithStatsAsync() {
cpuUsage,
memoryUsage,
image: container.Image,
ports: container.Ports,
ports: container.Ports as Dockerode.Port[] | undefined,
};
});