Report cancelled SDK uninstalls accurately - #2731
Conversation
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
|
@dotnet-policy-service agree |
nagilson
left a comment
There was a problem hiding this comment.
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.
|
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)
|
Hi @nagilson, are there any areas where I need to improve? If so, please let me know. Thank u! |
nagilson
left a comment
There was a problem hiding this comment.
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.
Co-authored-by: Noah Gilson <OTAKUPENGUINOP@GMAIL.COM>
Co-authored-by: Noah Gilson <OTAKUPENGUINOP@GMAIL.COM>
c6cbdae to
afe9e6f
Compare
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
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! |
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.) |
This reverts commit 4b9dff9.
|
@mthalman Great feedback on the status code handler; I've applied a fix. |
Summary
@vscode/sudo-promptUAC dismissal message as user cancellationRoot cause
When the Windows UAC prompt was dismissed,
@vscode/sudo-promptreturnedUser did not grant permission.. The global uninstall worker discarded thatstatus and replaced it with an arbitrary error code and a fixed
Another install may be in progressmessage.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 testinvscode-dotnet-runtime-library: 255 passing, 7 pendingnpm run test:lm-toolsinvscode-dotnet-runtime-extension: 68 passingFixes #2698