From 8f6c909acdb0abff08ff0eeac9d893a5212b574f Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 28 Aug 2026 12:28:26 -0700 Subject: [PATCH] add missing const, add key check --- server/src/service/network/DockerProvider.ts | 15 ++++++++++++--- server/src/types/network.ts | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/server/src/service/network/DockerProvider.ts b/server/src/service/network/DockerProvider.ts index 543f73011..a24ad2c18 100644 --- a/server/src/service/network/DockerProvider.ts +++ b/server/src/service/network/DockerProvider.ts @@ -47,19 +47,28 @@ export class DockerProvider implements IStatusProvider { if (!url) throw new AppError({ message: "Docker host URL is required", status: 422, service: SERVICE_NAME, method: "toDockerOptions" }); if (url.startsWith("unix://")) { const socketPath = url.slice("unix://".length); - if (!socketPath.startsWith("/")) throw new Error(`Invalid Docker host URL: ${url}`); + if (!socketPath.startsWith("/")) + throw new AppError({ message: `Invalid Docker host URL: ${url}`, status: 422, service: SERVICE_NAME, method: "toDockerOptions" }); return { socketPath }; } if (url.startsWith("/")) return { socketPath: url }; const match = url.match(/^ssh:\/\/(?:([^@\s]+)@)?([^\s/:@]+)(?::(\d{1,5}))?\/?$/); - if (!match) throw new AppError({ message: "Invalid Docker host URL", status: 422, service: SERVICE_NAME, method: "toDockerOptions" }); + if (!match) throw new AppError({ message: `Invalid Docker host URL: ${url}`, status: 422, service: SERVICE_NAME, method: "toDockerOptions" }); const [, username, host, port] = match; if (!username) throw new AppError({ message: "SSH Docker host URL requires a user: ssh://user@host", status: 422, service: SERVICE_NAME, - method: "ToDockerOptions", + method: "toDockerOptions", + }); + + if (!monitor.sshPrivateKey) + throw new AppError({ + message: "SSH Docker host requires a private key", + status: 422, + service: SERVICE_NAME, + method: "toDockerOptions", }); return { protocol: "ssh", diff --git a/server/src/types/network.ts b/server/src/types/network.ts index f92268f42..62f359b46 100644 --- a/server/src/types/network.ts +++ b/server/src/types/network.ts @@ -97,7 +97,7 @@ export interface HardwareStatusPayload { } // Docker host monitoring -export const DockerContainerStates = ["created", "running", "paused", "restarting", "removing", "exited", "dead"]; +export const DockerContainerStates = ["created", "running", "paused", "restarting", "removing", "exited", "dead"] as const; export type DockerContainerState = (typeof DockerContainerStates)[number]; export const DockerHealthStatuses = ["healthy", "unhealthy", "starting", "none"] as const;