microsoft / microsoft/aspire

WithTerminal executables produce DcpExecutor errors when stdout log streaming starts

Open
#19,606 1 comment 0 reactions 1 assignee Claimed by @karolz-ms View on GitHub
area-orchestrator area-terminals triage:bot-seen
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

### Describe the bug

When an executable resource is configured with `.WithTerminal()`, the AppHost still attempts to stream stdout logs for that executable. DCP rejects the request with `400 BadRequest` because terminal-backed executables do not expose stdout logs, and `Aspire.Hosting.Dcp.DcpExecutor` logs a failure for every terminal-backed resource.

### Expected behavior

The AppHost/DCP resource watcher should not start a stdout log stream for an executable configured to use a terminal.

### Actual behavior

The Debug Console reports:

```text
fail: Aspire.Hosting.Dcp.DcpExecutor[0]
Error streaming logs for dev-shell-kmupbpxy.
k8s.Autorest.HttpOperationException: Operation returned an invalid status code 'BadRequest', response body {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"stdout logs are not available for Executable '/dev-shell-kmupbpxy' because it is configured to use a terminal","reason":"BadRequest","code":400}

at Aspire.Hosting.Dcp.DcpKubernetesClient.ReadSubResourceAsStreamAsync(...) in /_/src/Aspire.Hosting/Dcp/DcpKubernetesClient.cs:line 76
at Aspire.Hosting.Dcp.KubernetesService.GetLogStreamAsync(...) in /_/src/Aspire.Hosting/Dcp/KubernetesService.cs:line 347
at Aspire.Hosting.Dcp.ResourceLogSource`1.GetAsyncEnumerator(...) in /_/src/Aspire.Hosting/Dcp/ResourceLogSource.cs:line 117
at Aspire.Hosting.Dcp.DcpResourceWatcher.StartLogStream(...) in /_/src/Aspire.Hosting/Dcp/DcpResourceWatcher.cs:line 639
```

The same failure occurs for each `.WithTerminal()` resource.

### Reproduction steps

1. Enable terminal commands in `aspire.config.json`:

```json
{
"features": {
"terminalCommandsEnabled": "true"
}
}
```

2. Add a terminal-backed executable to the AppHost:

```csharp
#pragma warning disable ASPIRETERMINAL001
builder.AddExecutable("dev-shell", "pwsh", "..", "-NoLogo", "-NoProfile")
.WithTerminal();
#pragma warning restore ASPIRETERMINAL001

builder.Build().Run();
```

3. Launch the AppHost from the VS Code Aspire integration.
4. Request logs for the terminal-backed resource, either by selecting it in the VS Code Debug Console or by running `aspire logs dev-shell`.
5. Observe the AppHost-side `Error streaming logs for resource dev-shell-...` message. In the CLI case, the client prints only lifecycle messages and exits with code `0`, while the AppHost log records the streaming error.

This was reproduced in a second, fresh debug session. Startup alone remained clean; the error appeared immediately when `aspire logs dev-shell` requested the terminal resource logs.

The CLI debug log confirms that the terminal host is resolved and both resources start before log streaming fails:

```text
Resolved terminal host 'dev-shell-terminalhost-0' for target 'dev-shell' replica 0 ...
Resource dev-shell-terminalhost-0/... changed state: Running
Resource dev-shell/... changed state: Running
```

### Environment

- Aspire AppHost SDK: `13.5.2`
- Aspire CLI: `13.5.2+a22cec24d76e764b3681977e314ab4a0aeed0240` (stable)
- .NET SDK: `10.0.204`
- OS: Windows `10.0.26200`, ARM64
- Launch path: VS Code Aspire integration (`aspire run` with the extension backchannel)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.