From b4e2d274b1f8320968489fcd9c434bf811cfbd74 Mon Sep 17 00:00:00 2001 From: Elijah <88380595+elijahdev0@users.noreply.github.com> Date: Mon, 29 Jun 2026 13:10:19 -0400 Subject: [PATCH] fix: resolve server from parent entity in deployment.readLogs (#4689) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The readLogs endpoint only checked deployment.serverId and deployment.schedule?.serverId to determine where to read log files. For application and compose deployments on remote servers, serverId is not stored on the deployment record — the server is resolved from the parent entity (application.serverId, compose.serverId). This caused readLogs to fall through to local execAsync, which would silently fail (2>/dev/null) because the log file lives on the remote server, returning empty content. Fix by loading the compose relation in findDeploymentById and adding fallback resolution through application?.serverId and compose?.serverId. Fixes #4687 Co-authored-by: Roo --- apps/dokploy/server/api/routers/deployment.ts | 6 +++++- packages/server/src/services/deployment.ts | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/dokploy/server/api/routers/deployment.ts b/apps/dokploy/server/api/routers/deployment.ts index d17a04dfb..0d7a91371 100644 --- a/apps/dokploy/server/api/routers/deployment.ts +++ b/apps/dokploy/server/api/routers/deployment.ts @@ -243,7 +243,11 @@ export const deploymentRouter = createTRPCRouter({ } const command = `tail -n ${input.tail} "${deployment.logPath}" 2>/dev/null || echo ""`; - const serverId = deployment.serverId || deployment.schedule?.serverId; + const serverId = + deployment.serverId || + deployment.schedule?.serverId || + deployment.application?.serverId || + deployment.compose?.serverId; if (serverId) { const { stdout } = await execAsyncRemote(serverId, command); return stdout; diff --git a/packages/server/src/services/deployment.ts b/packages/server/src/services/deployment.ts index a5ff57779..0431de18e 100644 --- a/packages/server/src/services/deployment.ts +++ b/packages/server/src/services/deployment.ts @@ -84,6 +84,7 @@ export const findDeploymentById = async (deploymentId: string) => { where: eq(deployments.deploymentId, deploymentId), with: { application: true, + compose: true, schedule: true, }, });