Skip to content

Report cancelled SDK uninstalls accurately - #2731

Merged
nagilson merged 12 commits into
dotnet:mainfrom
GaTTGeng:fix/2698-surface-uninstall-error
Aug 4, 2026
Merged

Report cancelled SDK uninstalls accurately#2731
nagilson merged 12 commits into
dotnet:mainfrom
GaTTGeng:fix/2698-surface-uninstall-error

Conversation

@GaTTGeng

Copy link
Copy Markdown
Contributor

Summary

  • preserve the failure reason returned by the global SDK uninstaller
  • recognize the @vscode/sudo-prompt UAC dismissal message as user cancellation
  • report a dismissed elevation prompt as a cancelled uninstall instead of suggesting that another install may be in progress
  • add regression coverage for the library failure propagation and the final language-model-facing message

Root cause

When the Windows UAC prompt was dismissed, @vscode/sudo-prompt returned
User did not grant permission.. The global uninstall worker discarded that
status and replaced it with an arbitrary error code and a fixed
Another install may be in progress message.

User impact

Copilot and other callers now receive an accurate cancellation message with
guidance to retry and accept the elevation prompt. Other uninstall failures
continue to use the existing generic guidance.

Validation

  • npm test in vscode-dotnet-runtime-library: 255 passing, 7 pending
  • npm run test:lm-tools in vscode-dotnet-runtime-extension: 68 passing

Fixes #2698

GaTTGeng added 4 commits June 19, 2026 09:35
When a Windows user dismisses the UAC dialog during global SDK uninstall,
@vscode/sudo-prompt surfaces "User did not grant permission." That string
matched none of the existing tokens in isUserCancellationMessage, so the
LLM tool path classified the cancellation as a generic failure and showed
the wrong retry guidance. Broaden the regex to recognize it, and export
the helper so the extension command path can reuse it (#2698).
uninstallGlobal previously discarded the installer's status string and
returned the arbitrary code 117778 with a fixed "Another install may be
in progress" message. When the user dismisses the UAC dialog the status
already carries "User did not grant permission.", so propagate it into
the DotnetUninstallFailed event and the return value instead. Add a unit
test that stubs both global installers to assert the surfaced text (#2698).
The wrapper at the extension command path used to claim every non-zero
uninstallGlobal result was "may have been cancelled, blocked by another
install in progress, or require manual removal", and embedded the raw
result inside "(code ...)". Now that uninstallGlobal forwards the
elevation provider's reason string, detect the cancellation case via
isUserCancellationMessage and emit a clear "admin/elevation prompt was
dismissed" message; for non-numeric reasons drop the "code" wrapping
since the result already reads as text (#2698).
Move uninstall failure formatting into a testable helper and verify that dismissing the elevation prompt is reported as a cancellation rather than an unrelated installer conflict.

Fix #2698
@GaTTGeng GaTTGeng changed the title [codex] Report cancelled SDK uninstalls accurately Report cancelled SDK uninstalls accurately Jun 19, 2026
@GaTTGeng

Copy link
Copy Markdown
Contributor Author

@dotnet-policy-service agree

@GaTTGeng
GaTTGeng marked this pull request as ready for review June 19, 2026 01:55
Copilot AI review requested due to automatic review settings June 19, 2026 01:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread vscode-dotnet-runtime-library/src/Acquisition/DotnetCoreAcquisitionWorker.ts Outdated
Comment thread vscode-dotnet-runtime-extension/src/LanguageModelTools.ts Outdated

@nagilson nagilson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for taking this on! You did a great job investigating. My feedback is mostly nitpicking and enhancements but happy to move this forward afterward and don't see any overall issues.

Comment thread vscode-dotnet-runtime-extension/src/extension.ts
Comment thread vscode-dotnet-runtime-extension/src/LanguageModelTools.ts Outdated
Comment thread vscode-dotnet-runtime-library/src/Acquisition/DotnetCoreAcquisitionWorker.ts Outdated
Comment thread vscode-dotnet-runtime-library/src/test/unit/DotnetCoreAcquisitionWorker.test.ts Outdated
Comment thread vscode-dotnet-runtime-library/src/test/unit/DotnetCoreAcquisitionWorker.test.ts Outdated
@GaTTGeng

Copy link
Copy Markdown
Contributor Author

Thank you so much for the thorough review, @nagilson ! This is my first contribution to an open-source project, and receiving such detailed and constructive feedback genuinely means a lot to me. I'll work through each of your suggestions.

- Fix uninstallGlobal to emit DotnetUninstallSkipped and return '0'
  when other dependents remain instead of falling through to the
  failure path (Copilot)
- Move buildUninstallFailureMessage into ErrorMessageUtilities.ts to
  avoid circular dependency between extension.ts and LanguageModelTools
  (nagilson)
- Keep isUserCancellationMessage private in both modules (nagilson)
- Trim result before numeric detection and use Number.isInteger instead
  of regex for readability (Copilot + nagilson)
- Remove redundant failureDetails variable (nagilson)
- Drop unnecessary VSCODE_DOTNET_RUNTIME_DISABLE_MUTEX env toggle in
  test (nagilson)
- Parameterize prototype patching for Linux/WinMac installers to reduce
  duplication in regression test (nagilson)
@GaTTGeng

Copy link
Copy Markdown
Contributor Author

Hi @nagilson, are there any areas where I need to improve? If so, please let me know. Thank u!

Comment thread vscode-dotnet-runtime-extension/src/ErrorMessageUtilities.ts Outdated
Comment thread vscode-dotnet-runtime-extension/src/ErrorMessageUtilities.ts Outdated

@nagilson nagilson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for your kind words, you've done a great job for your first open-source PR especially! I appreciate the effort you put into applying the fixes. I have a remaining nitpick and once that is resolved this looks good to go.

Comment thread vscode-dotnet-runtime-extension/src/LanguageModelTools.ts Outdated
Co-authored-by: Noah Gilson <OTAKUPENGUINOP@GMAIL.COM>
Copilot AI review requested due to automatic review settings June 23, 2026 01:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Co-authored-by: Noah Gilson <OTAKUPENGUINOP@GMAIL.COM>
Copilot AI review requested due to automatic review settings June 23, 2026 01:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings June 23, 2026 06:35
@GaTTGeng
GaTTGeng force-pushed the fix/2698-surface-uninstall-error branch from c6cbdae to afe9e6f Compare June 23, 2026 06:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 23, 2026 23:53
@nagilson
nagilson requested a review from a team June 23, 2026 23:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread vscode-dotnet-runtime-extension/src/ErrorMessageUtilities.ts
Comment thread vscode-dotnet-runtime-extension/src/ErrorMessageUtilities.ts
@GaTTGeng

Copy link
Copy Markdown
Contributor Author

Thank you for the kind words, and for the thorough review — it made the fix much better than what I started with. It's been a great experience contributing to this project!

@nagilson
nagilson requested a review from mthalman July 20, 2026 21:18

@mthalman mthalman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There should also be handling of 1602 cancellation for uninstallation within WinMacGlobalInstaller. This is already done today for installation but not uninstallation. See

else if (installerResult === '1602')
{
// Special code for when user cancels the install
const err = new DotnetInstallCancelledByUserError(new EventCancellationError('DotnetInstallCancelledByUserError',
`The install of .NET was cancelled by the user. Aborting.`), install);
this.acquisitionContext.eventStream.post(err);
throw err.error;
}

@nagilson

Copy link
Copy Markdown
Member

There should also be handling of 1602 cancellation for uninstallation within WinMacGlobalInstaller. This is already done today for installation but not uninstallation. See

else if (installerResult === '1602')
{
// Special code for when user cancels the install
const err = new DotnetInstallCancelledByUserError(new EventCancellationError('DotnetInstallCancelledByUserError',
`The install of .NET was cancelled by the user. Aborting.`), install);
this.acquisitionContext.eventStream.post(err);
throw err.error;
}

Working on this. (For context for the contributor, we switched to a more stringent approval process so I can't approve your PR since I pushed to it last but I will get this through, you did your due diligence.)

Copilot AI review requested due to automatic review settings July 21, 2026 20:44
@nagilson
nagilson requested a review from mthalman July 21, 2026 20:46
@nagilson

Copy link
Copy Markdown
Member

@mthalman Great feedback on the status code handler; I've applied a fix.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread vscode-dotnet-runtime-library/src/EventStream/EventStreamEvents.ts
Copilot AI review requested due to automatic review settings July 21, 2026 20:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@nagilson
nagilson disabled auto-merge July 23, 2026 21:48
@nagilson
nagilson enabled auto-merge July 23, 2026 21:48
@nagilson
nagilson added this pull request to the merge queue Jul 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Jul 23, 2026
@nagilson
nagilson added this pull request to the merge queue Jul 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Jul 24, 2026
@nagilson
nagilson added this pull request to the merge queue Aug 4, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Aug 4, 2026
@nagilson
nagilson merged commit f75de5e into dotnet:main Aug 4, 2026
8 checks passed
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.

Improve “Another install may be in progress” text - this shows when cancelling the uninstallation by dismissing the UAC/admin prompt.

4 participants