Skip to content

Suppress error notifications for extension prompt cancellation in CLI#14547

Merged
adamint merged 2 commits intomicrosoft:release/13.2from
adamint:dev/adamint/fix-cancel-input-errors
Feb 25, 2026
Merged

Suppress error notifications for extension prompt cancellation in CLI#14547
adamint merged 2 commits intomicrosoft:release/13.2from
adamint:dev/adamint/fix-cancel-input-errors

Conversation

@adamint
Copy link
Copy Markdown
Member

@adamint adamint commented Feb 18, 2026

Description

When a user cancels an input prompt in the VS Code extension (e.g., dismissing the template selection during aspire new), the CLI's ExtensionBackchannel throws ExtensionOperationCanceledException. Previously, the ExtensionInteractionService catch blocks in ConfirmAsync, PromptForSelectionAsync, and PromptForSelectionsAsync would call DisplayError before re-throwing the exception, causing an error notification to appear in VS Code even though the cancellation was user-initiated.

This PR fixes the issue by suppressing DisplayError calls when the exception is ExtensionOperationCanceledException:

  • ExtensionInteractionService: Skip DisplayError when the exception is ExtensionOperationCanceledException in prompt catch blocks (ConfirmAsync, PromptForSelectionAsync, PromptForSelectionsAsync) and the task channel reader's catch block.
  • Program.cs: Add ExtensionOperationCanceledException to the global exception handler's cancellation suppression check as a safety net, so any uncaught extension cancellation exceptions are also silently handled.

(tested manually)

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
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No
  • Does the change require an update in our Aspire docs?
    • Yes
    • No

When a user cancels an input prompt in the VS Code extension, the CLI's
ExtensionBackchannel throws ExtensionOperationCanceledException. Previously,
the ExtensionInteractionService catch blocks in ConfirmAsync,
PromptForSelectionAsync, and PromptForSelectionsAsync would call DisplayError
before re-throwing, causing an error notification in VS Code even though
the cancellation was user-initiated.

Changes:
- ExtensionInteractionService: Skip DisplayError when the exception is
  ExtensionOperationCanceledException in prompt catch blocks and the
  task channel reader.
- Program.cs: Add ExtensionOperationCanceledException to the global
  handler's cancellation suppression check as a safety net.
Copilot AI review requested due to automatic review settings February 18, 2026 17:58
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 18, 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 -- 14547

Or

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

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

This PR aims to suppress error notifications when users cancel VS Code extension prompts (e.g., dismissing template selection during aspire new). When cancellation occurs, the CLI's ExtensionBackchannel throws ExtensionOperationCanceledException, which should not trigger error displays since it represents intentional user action.

Changes:

  • Modified ExtensionInteractionService to skip DisplayError calls when catching ExtensionOperationCanceledException in prompt methods and the task channel reader
  • Updated Program.cs global exception handler to suppress logging/display for ExtensionOperationCanceledException

Reviewed changes

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

File Description
src/Aspire.Cli/Interaction/ExtensionInteractionService.cs Added checks to suppress DisplayError for ExtensionOperationCanceledException in ConfirmAsync, PromptForSelectionAsync, PromptForSelectionsAsync, and the channel reader catch block
src/Aspire.Cli/Program.cs Modified global exception handler condition to suppress error logging/display for ExtensionOperationCanceledException

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@adamint adamint changed the base branch from main to release/13.2 February 24, 2026 16:30
@adamint adamint merged commit a68b97f into microsoft:release/13.2 Feb 25, 2026
676 of 679 checks passed
@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
…#14547)

* Suppress error notifications for extension cancellation in CLI

When a user cancels an input prompt in the VS Code extension, the CLI's
ExtensionBackchannel throws ExtensionOperationCanceledException. Previously,
the ExtensionInteractionService catch blocks in ConfirmAsync,
PromptForSelectionAsync, and PromptForSelectionsAsync would call DisplayError
before re-throwing, causing an error notification in VS Code even though
the cancellation was user-initiated.

Changes:
- ExtensionInteractionService: Skip DisplayError when the exception is
  ExtensionOperationCanceledException in prompt catch blocks and the
  task channel reader.
- Program.cs: Add ExtensionOperationCanceledException to the global
  handler's cancellation suppression check as a safety net.

* Update src/Aspire.Cli/Program.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@github-actions github-actions bot locked and limited conversation to collaborators Mar 28, 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.

3 participants