Skip to content

fix(api): respect service_name query param in application logs endpoint - #12066

Merged
andrasbacsai merged 1 commit into
coollabsio:mainfrom
Furox-Art:fix/api-logs-service-name
Oct 1, 2026
Merged

andrasbacsai merged 1 commit into
coollabsio:mainfrom
Furox-Art:fix/api-logs-service-name

Conversation

@Furox-Art

Copy link
Copy Markdown
Contributor

Fixes #12055.

Problem

GET /api/v1/applications/{uuid}/logs ignored service_name and always returned logs from the first container ($containers->first()), so coolify app logs --service <name> could show logs from the wrong Compose service.

Fix

When service_name is present, select the container whose Labels contain the matching com.docker.compose.service=<name> entry (exact, comma-delimited match via regex so web can't match web2) and return 404 when no running container matches. Without the parameter, behavior is unchanged. The OpenAPI docblock now documents the parameter.

Testing

php -l clean. Repro per #12055: compose app with web + worker — ?service_name=worker now returns worker logs; an unknown name returns No running container found for service_name 'x'.

GET /applications/{uuid}/logs ignored service_name and always returned
logs from the first container, so 'coolify app logs --service' could show
logs from the wrong Compose service. When service_name is present, select
the container whose labels contain the matching
com.docker.compose.service entry and 404 when nothing matches.
@Furox-Art

Copy link
Copy Markdown
Contributor Author

Friendly maintainer review request: this contribution has been updated with the latest fixes and checks. Please review when convenient. Thank you.

@andrasbacsai
andrasbacsai merged commit 6023f49 into coollabsio:main Oct 1, 2026
3 checks passed
yannisgu added a commit to yannisgu/coolify that referenced this pull request Oct 21, 2026
GET /applications/{uuid}/logs already accepts service_name (a key under
`services:`) to pick the container of a Docker Compose service, and the
preview logs endpoint documents it too. But preview containers carry the
Compose service name with a -pr-<id> suffix, so
/previews/{pull_request_id}/logs?service_name=worker always returned 404.
coolify-cli sends the plain service name for its --service flag.

Match the plain name and the suffixed preview name. Without service_name
the first container is still returned; a service without a running
container still returns 404.

Ported from github.com/yannisgu/coolify fix/api-logs-service-name
(coollabsio#11919); the non-preview part is already upstream
(coollabsio#12066, 8bbab72).
yannisgu added a commit to yannisgu/coolify that referenced this pull request Oct 21, 2026
GET /applications/{uuid}/logs already accepts service_name (a key under
`services:`) to pick the container of a Docker Compose service, and the
preview logs endpoint documents it too. But preview containers carry the
Compose service name with a -pr-<id> suffix, so
/previews/{pull_request_id}/logs?service_name=worker always returned 404.
coolify-cli sends the plain service name for its --service flag.

Match the plain name and the suffixed preview name. Without service_name
the first container is still returned; a service without a running
container still returns 404.

Ported from github.com/yannisgu/coolify fix/api-logs-service-name
(coollabsio#11919); the non-preview part is already upstream
(coollabsio#12066, 8bbab72).
yannisgu added a commit to yannisgu/coolify that referenced this pull request Oct 21, 2026
GET /applications/{uuid}/logs already accepts service_name (a key under
`services:`) to pick the container of a Docker Compose service, and the
preview logs endpoint documents it too. But preview containers carry the
Compose service name with a -pr-<id> suffix, so
/previews/{pull_request_id}/logs?service_name=worker always returned 404.
coolify-cli sends the plain service name for its --service flag.

Match the plain name and the suffixed preview name. Without service_name
the first container is still returned; a service without a running
container still returns 404.

Ported from github.com/yannisgu/coolify fix/api-logs-service-name
(coollabsio#11919); the non-preview part is already upstream
(coollabsio#12066, 8bbab72).
yannisgu added a commit to yannisgu/coolify that referenced this pull request Oct 25, 2026
GET /applications/{uuid}/logs already accepts service_name (a key under
`services:`) to pick the container of a Docker Compose service, and the
preview logs endpoint documents it too. But preview containers carry the
Compose service name with a -pr-<id> suffix, so
/previews/{pull_request_id}/logs?service_name=worker always returned 404.
coolify-cli sends the plain service name for its --service flag.

Match the plain name and the suffixed preview name. Without service_name
the first container is still returned; a service without a running
container still returns 404.

Ported from github.com/yannisgu/coolify fix/api-logs-service-name
(coollabsio#11919); the non-preview part is already upstream
(coollabsio#12066, 8bbab72).
yannisgu added a commit to yannisgu/coolify that referenced this pull request Oct 26, 2026
GET /applications/{uuid}/logs already accepts service_name (a key under
`services:`) to pick the container of a Docker Compose service, and the
preview logs endpoint documents it too. But preview containers carry the
Compose service name with a -pr-<id> suffix, so
/previews/{pull_request_id}/logs?service_name=worker always returned 404.
coolify-cli sends the plain service name for its --service flag.

Match the plain name and the suffixed preview name. Without service_name
the first container is still returned; a service without a running
container still returns 404.

Ported from github.com/yannisgu/coolify fix/api-logs-service-name
(coollabsio#11919); the non-preview part is already upstream
(coollabsio#12066, 8bbab72).
yannisgu added a commit to yannisgu/coolify that referenced this pull request Oct 26, 2026
GET /applications/{uuid}/logs already accepts service_name (a key under
`services:`) to pick the container of a Docker Compose service, and the
preview logs endpoint documents it too. But preview containers carry the
Compose service name with a -pr-<id> suffix, so
/previews/{pull_request_id}/logs?service_name=worker always returned 404.
coolify-cli sends the plain service name for its --service flag.

Match the plain name and the suffixed preview name. Without service_name
the first container is still returned; a service without a running
container still returns 404.

Ported from github.com/yannisgu/coolify fix/api-logs-service-name
(coollabsio#11919); the non-preview part is already upstream
(coollabsio#12066, 8bbab72).
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Application logs API ignores service_name for Docker Compose applications

2 participants