- Notifications
You must be signed in to change notification settings - Fork807
Redirect human-readable messages to stderr when --format json is used#14572
Redirect human-readable messages to stderr when --format json is used#14572mitchdenny wants to merge 2 commits intorelease/13.2from
Conversation
When running `aspire run --detach --format json`, messages like"Finding apphosts..." and "Stopping previous instance..." were writtento stdout alongside the JSON output, making it impossible to parse theJSON programmatically.Add a `UseStderrForMessages` property to IInteractionService. Whenenabled, ConsoleInteractionService routes all human-readable displaymethods through stderr while keeping DisplayRawText on stdout forstructured output. The property is set in ExecuteDetachedAsync whenthe output format is JSON.Fixes#14423Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
github-actionsbot commentedFeb 19, 2026 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
🚀Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh| bash -s -- 14572Or
iex"& {$(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14572" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Pull request overview
This pull request fixes issue#14423 where human-readable messages were being written to stdout alongside JSON output when runningaspire run --detach --format json, making the JSON output unparseable by automated tools.
Changes:
- Added
UseStderrForMessagesproperty toIInteractionServiceto enable routing human-readable messages to stderr - Modified
ConsoleInteractionServiceto route display methods through aMessageConsoleproperty that returns stderr when the flag is set - Set
UseStderrForMessages = trueinRunCommand.ExecuteDetachedAsyncwhen--format jsonis specified
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Aspire.Cli/Interaction/IInteractionService.cs | AddedUseStderrForMessages property with default no-op implementation |
| src/Aspire.Cli/Interaction/ConsoleInteractionService.cs | ImplementedUseStderrForMessages property and routed all message display methods throughMessageConsole that redirects to stderr when flag is set;DisplayRawText correctly stays on stdout |
| src/Aspire.Cli/Commands/RunCommand.cs | SetsUseStderrForMessages = true when running in detached mode with JSON format |
Uh oh!
There was an error while loading.Please reload this page.
github-actionsbot commentedFeb 19, 2026 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
🎬 CLI E2E Test RecordingsThe following terminal recordings are available for commit
📹 Recordings uploaded automatically fromCI run #22208382250 |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
…enum- Add ConsoleOutput enum (Standard, Error) for explicit console targeting- Replace DIM UseStderrForMessages with standard DefaultConsole property- Add optional ConsoleOutput parameter to DisplayRawText for explicit targeting- Update all IInteractionService implementationsCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
mitchdenny commentedFeb 20, 2026
/deployment-test |
🚀Deployment tests starting on PR#14572... This will deploy to real Azure infrastructure. Results will be posted here when complete. |
✅Deployment E2E Tests passed Summary: 21 passed, 0 failed, 0 cancelled Passed Tests
🎬 Terminal Recordings
|
Summary
When running
aspire run --detach --format json, human-readable messages like "Finding apphosts..." and "Stopping previous instance..." were written to stdout alongside the JSON output, making it impossible to parse the JSON programmatically.Changes
UseStderrForMessagesproperty toIInteractionServicewith a default no-op implementationConsoleInteractionServiceroutes all human-readable display methods (DisplayMessage,DisplaySuccess,DisplayError,ShowStatusAsync, etc.) through aMessageConsoleproperty that returns_errorConsole(stderr) when the flag is setDisplayRawTextremains on stdout — this is used for the structured JSON outputExecuteDetachedAsyncinRunCommandsetsUseStderrForMessages = truewhen--format jsonis specifiedBefore
After
Human-readable messages still appear on stderr so users can see progress when running interactively, but
stdout | jqnow works correctly.Fixes#14423