Skip to content

Write empty JSON from aspire ps to stdout#14662

Merged
JamesNK merged 2 commits intorelease/13.2from
jamesnk/write-json-stdout
Feb 25, 2026
Merged

Write empty JSON from aspire ps to stdout#14662
JamesNK merged 2 commits intorelease/13.2from
jamesnk/write-json-stdout

Conversation

@JamesNK
Copy link
Copy Markdown
Member

@JamesNK JamesNK commented Feb 24, 2026

Description

I noticed aspire ps was incorrectly writing an empty result to stderr instead of stdout.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 24, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14662

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14662"

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes aspire ps --format json to emit an empty JSON array to stdout (not stderr) when there are no running AppHosts, aligning with structured-output expectations in the CLI.

Changes:

  • Route the no-results JSON output ([]) explicitly to stdout.
  • Expand PsCommand JSON tests to validate deserialization and field mapping for non-empty results.
  • Add a regression assertion ensuring no-results JSON output is [] on stdout.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Aspire.Cli/Commands/PsCommand.cs Writes [] via DisplayRawText(..., ConsoleOutput.Standard) to guarantee stdout for JSON no-results case.
tests/Aspire.Cli.Tests/Commands/PsCommandTests.cs Adds/extends coverage for JSON output validity and asserts [] is written to stdout for no-results.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 25, 2026

🎬 CLI E2E Test Recordings

The following terminal recordings are available for commit 6ba9aa7:

Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AgentInitCommand_WithMalformedMcpJson_ShowsErrorAndExitsNonZero ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
CreateAndDeployToDockerCompose ▶️ View Recording
CreateAndDeployToDockerComposeInteractive ▶️ View Recording
CreateAndPublishToKubernetes ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateEmptyAppHostProject ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateStartWaitAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording

📹 Recordings uploaded automatically from CI run #22375717145

@JamesNK JamesNK enabled auto-merge (squash) February 25, 2026 00:15
@JamesNK JamesNK merged commit 05d2f7a into release/13.2 Feb 25, 2026
675 of 679 checks passed
@JamesNK JamesNK deleted the jamesnk/write-json-stdout branch February 25, 2026 01:20
@dotnet-policy-service dotnet-policy-service bot added this to the 13.2 milestone Feb 25, 2026
Copilot AI pushed a commit that referenced this pull request Mar 10, 2026
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants