Fix Watson #1488201: Surface cookiecutter install failures without crashing VS#8511
Merged
StellaHuang95 merged 1 commit intoMay 29, 2026
Merged
Conversation
…ashing VS
WaitForOutput throws ProcessException when a subprocess (venv creation,
pip install, etc.) exits non-zero. The install paths
(CreateVenvWithoutPipThenInstallPip and InstallPackage) did not catch it,
and CreateCookiecutterEnv re-wrapped it as CriticalException to 'fail
properly' - but the outer catch in
CookiecutterViewModel.EnsureCookiecutterIsInstalledAsync explicitly
ignores critical exceptions (when !ex.IsCriticalException()), so the
CriticalException escaped the message-loop boundary and crashed VS.
* Add private WaitForCookiecutterInstallOutput helper that catches
ProcessException, writes a friendly message + the captured stderr
to the redirector, and rethrows as InvalidOperationException.
* Use the helper at the three install-path WaitForOutput call sites
(lines 167, 184, 212 of CookiecutterClient.cs).
* Drop the CriticalException re-wrap in CreateCookiecutterEnv - the
outer catch in EnsureCookiecutterIsInstalledAsync already handles
non-critical exceptions and surfaces the failure to the user.
* Add Strings.CookiecutterInstallFailed resource string.
Watson #1488201 - 12 hits, builds 17.11.35219.272 - 18.3.11520.95.
c66d692 to
551f18a
Compare
|
Contributor
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
rchiodo
approved these changes
May 28, 2026
Contributor
rchiodo
left a comment
There was a problem hiding this comment.
Approved via Review Center.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Issue
Watson #1488201 —
CLR_EXCEPTION_Microsoft.CookiecutterTools.Model.ProcessExceptionfromCookiecutterClient.WaitForOutput(12 hits, builds 17.11.35219.272 – 18.3.11520.95).Problem
The cookiecutter feature creates a side venv, installs pip, then
pip install cookiecutter. If any of those subprocesses fail (no network, corporate proxy blocking PyPI, corrupt interpreter), the subprocess exits non-zero,WaitForOutputthrowsProcessException, and the exception escapes the WPF Dispatcher → crashes VS.The original code in
CreateCookiecutterEnvwrapped only the first install step intry { … } throw new CriticalException(...). The outer handler inCookiecutterViewModel.EnsureCookiecutterIsInstalledAsyncusescatch (Exception ex) when (!ex.IsCriticalException())— so the wrappedCriticalExceptionpropagated uncaught anyway, and the other two install paths (pip install pip,pip install cookiecutter) had no guard at all.Fix
WaitForCookiecutterInstallOutput(...)that wrapsWaitForOutput, catchesProcessException, writes a formatted error + stderr lines to_redirector, and re-throws asInvalidOperationException.InvalidOperationExceptionis non-critical, so the outer handler catches it cleanly → sets status toFailed, returnsfalse, fires telemetry.WaitForOutputcalls through the new helper.throw new CriticalException(...)wrap inCreateCookiecutterEnv(the comment claiming it was "needed for EnsureCookiecutterIsInstalledAsync to fail properly" was incorrect — it actually crashed VS).CookiecutterInstallFailedfor the formatted error message.Files changed
Python/Product/Cookiecutter/Model/CookiecutterClient.csPython/Product/Cookiecutter/Strings.resxPython/Product/Cookiecutter/Strings.Designer.cs