Skip to content

Commit 35be3c2

Browse files
authored
Ensure escape on TOML and requirements is treated as cancel. (#20739)
1 parent 5d9bc1e commit 35be3c2

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

src/client/pythonEnvironments/creation/provider/condaCreationProvider.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ async function createEnvironment(options?: CreateEnvironmentOptions): Promise<Cr
192192
throw ex;
193193
}
194194

195+
if (version === undefined) {
196+
traceError('Python version was not selected for creating conda environment.');
197+
return MultiStepAction.Cancel;
198+
}
195199
return MultiStepAction.Continue;
196200
},
197201
undefined,

src/client/pythonEnvironments/creation/provider/venvUtils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ export async function pickPackagesToInstall(
151151
});
152152
}
153153
packages.push({ installType: 'toml', source: tomlPath });
154+
} else {
155+
return MultiStepAction.Cancel;
154156
}
155157
} catch (ex) {
156158
if (ex === MultiStepAction.Back || ex === MultiStepAction.Cancel) {
@@ -192,6 +194,8 @@ export async function pickPackagesToInstall(
192194
installList.forEach((i) => {
193195
packages.push({ installType: 'requirements', installItem: i });
194196
});
197+
} else {
198+
return MultiStepAction.Cancel;
195199
}
196200
} catch (ex) {
197201
if (ex === MultiStepAction.Back || ex === MultiStepAction.Cancel) {

src/test/pythonEnvironments/creation/provider/condaCreationProvider.unit.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ suite('Conda Creation provider tests', () => {
7676
});
7777
pickPythonVersionStub.resolves(undefined);
7878

79-
assert.isUndefined(await condaProvider.createEnvironment());
79+
await assert.isRejected(condaProvider.createEnvironment());
8080
});
8181

8282
test('Create conda environment', async () => {

src/test/pythonEnvironments/creation/provider/venvUtils.unit.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ suite('Venv Utils test', () => {
8080
'[project]\nname = "spam"\nversion = "2020.0.0"\n[build-system]\nrequires = ["setuptools ~= 58.0", "cython ~= 0.29.0"]\n[project.optional-dependencies]\ntest = ["pytest"]\ndoc = ["sphinx", "furo"]',
8181
);
8282

83-
showQuickPickWithBackStub.rejects(windowApis.MultiStepAction.Cancel);
83+
showQuickPickWithBackStub.resolves(undefined);
8484

8585
await assert.isRejected(pickPackagesToInstall(workspace1));
8686
assert.isTrue(
@@ -215,7 +215,7 @@ suite('Venv Utils test', () => {
215215
return Promise.resolve([]);
216216
});
217217

218-
showQuickPickWithBackStub.rejects(windowApis.MultiStepAction.Cancel);
218+
showQuickPickWithBackStub.resolves(undefined);
219219

220220
await assert.isRejected(pickPackagesToInstall(workspace1));
221221
assert.isTrue(

0 commit comments

Comments
 (0)