fix: resolve server from parent entity in deployment.readLogs (#4689)

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 <roo@agent.com>
This commit is contained in:
Elijah
2026-06-29 13:10:19 -04:00
committed by GitHub
parent 24b02f5523
commit b4e2d274b1
2 changed files with 6 additions and 1 deletions

View File

@@ -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;

View File

@@ -84,6 +84,7 @@ export const findDeploymentById = async (deploymentId: string) => {
where: eq(deployments.deploymentId, deploymentId),
with: {
application: true,
compose: true,
schedule: true,
},
});