Skip to content

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

Open
elijahdev0 wants to merge 1 commit into
Dokploy:canaryfrom
elijahdev0:fix/deployment-readlogs-remote-server
Open

fix: resolve server from parent entity in deployment.readLogs#4689
elijahdev0 wants to merge 1 commit into
Dokploy:canaryfrom
elijahdev0:fix/deployment-readlogs-remote-server

Conversation

@elijahdev0

Copy link
Copy Markdown

Problem

The deployment.readLogs endpoint returns empty content for deployments on remote servers.

Root cause: The handler only checks deployment.serverId and deployment.schedule?.serverId to determine where to read the log file. For application and compose deployments, serverId is not stored on the deployment record — the server is resolved from the parent entity (application.serverId, compose.serverId).

When serverId is null, the handler falls through to local execAsync(command), which runs tail locally. But the log file lives on the remote server, so 2>/dev/null suppresses the "file not found" error and returns "".

Fix

  1. Load the compose relation in findDeploymentById (it already loads application and schedule)
  2. Fall back to application?.serverId and compose?.serverId in the readLogs handler

Reproduction

  1. Deploy a compose app to a remote server
  2. Call GET /api/deployment.readLogs?deploymentId=xxx&tail=100
  3. Before: returns \n (empty)
  4. After: returns actual log content

Fixes #4687

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 Dokploy#4687
@elijahdev0 elijahdev0 requested a review from Siumauricio as a code owner June 23, 2026 02:57
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

deployment.readLogs returns empty content instead of actual logs

1 participant