Skip to content

Stop command exits with 0 when no AppHost is running#14570

Open
mitchdenny wants to merge 2 commits intorelease/13.2from
fix/stop-exit-zero-when-nothing-running
Open

Stop command exits with 0 when no AppHost is running#14570
mitchdenny wants to merge 2 commits intorelease/13.2from
fix/stop-exit-zero-when-nothing-running

Conversation

@mitchdenny
Copy link
Member

Summary

When running aspire stop and no AppHost is running, the command now returns exit code 0 and displays an informational message instead of exit code 7 (FailedToFindProject) with an error message.

Stopping nothing is not an error condition - it's an idempotent success.

Changes

  • Changed StopCommand to return ExitCodeConstants.Success (0) instead of ExitCodeConstants.FailedToFindProject (7) when no running AppHost is found
  • Changed from DisplayError to DisplayMessage("information", ...) for the no-running-AppHost case, matching the pattern used by PsCommand

Addresses part of #14238

When running 'aspire stop' and no AppHost is running, the command now
returns exit code 0 and displays an informational message instead of
exit code 7 (FailedToFindProject) with an error message. This aligns
with the expected behavior that stopping nothing is not an error.

Fixes part of #14238

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 19, 2026 07:20
@github-actions
Copy link
Contributor

github-actions bot commented Feb 19, 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 -- 14570

Or

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

Copy link
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

This PR makes the aspire stop command idempotent by treating the absence of a running AppHost as a success condition rather than an error. When no AppHost is found, the command now returns exit code 0 with an informational message instead of exit code 7 with an error message. This aligns with Unix conventions where idempotent operations (like stopping a non-running service) are treated as successful.

Changes:

  • Modified StopCommand to return success (exit code 0) when no AppHost is running
  • Changed message display from error to informational for the no-running-AppHost case
  • Simplified error message handling by directly using the localized string

@github-actions
Copy link
Contributor

github-actions bot commented Feb 19, 2026

🎬 CLI E2E Test Recordings

The following terminal recordings are available for commit cbc5237:

Test Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ 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
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
ResourcesCommandShowsRunningResources ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording

📹 Recordings uploaded automatically from CI run #22174113658

@mitchdenny mitchdenny linked an issue Feb 19, 2026 that may be closed by this pull request
Validates that 'aspire stop' exits with code 0 and shows an
informational message when no AppHost is running, rather than
returning an error exit code.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI commands suggestions

1 participant

Comments