Skip to content

Commit a9e9c78

Browse files
authored
Fix issue 3561 - Spec.language may be null (#3583)
* Fix issue 3561
1 parent f5e6375 commit a9e9c78

File tree

4 files changed

+30
-15
lines changed

4 files changed

+30
-15
lines changed

news/2 Fixes/3561.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix crash when kernelspec is missing path or language

package-lock.json

Lines changed: 21 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/client/datascience/jupyterExecution.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ export class JupyterExecution implements IJupyterExecution, Disposable {
550550

551551
// See if any of their paths match
552552
return specs.findIndex(s => {
553-
if (info && s) {
553+
if (info && s && s.path) {
554554
return this.fileSystem.arePathsSame(s.path, info.path);
555555
}
556556
return false;
@@ -574,7 +574,7 @@ export class JupyterExecution implements IJupyterExecution, Disposable {
574574

575575
// For each get its details as we will likely need them
576576
const specDetails = await Promise.all(specs.map(async s => {
577-
if (s && s.path.length > 0 && await fs.pathExists(s.path)) {
577+
if (s && s.path && s.path.length > 0 && await fs.pathExists(s.path)) {
578578
return this.interpreterService.getInterpreterDetails(s.path);
579579
}
580580
}));
@@ -583,11 +583,11 @@ export class JupyterExecution implements IJupyterExecution, Disposable {
583583
const spec = specs[i];
584584
let score = 0;
585585

586-
if (spec && spec.path.length > 0 && info && spec.path === info.path) {
586+
if (spec && spec.path && spec.path.length > 0 && info && spec.path === info.path) {
587587
// Path match
588588
score += 10;
589589
}
590-
if (spec && spec.language.toLocaleLowerCase() === 'python') {
590+
if (spec && spec.language && spec.language.toLocaleLowerCase() === 'python') {
591591
// Language match
592592
score += 1;
593593

@@ -610,7 +610,7 @@ export class JupyterExecution implements IJupyterExecution, Disposable {
610610
}
611611
}
612612
}
613-
} else if (info && info.version_info && spec && spec.path.toLocaleLowerCase() === 'python') {
613+
} else if (info && info.version_info && spec && spec.path && spec.path.toLocaleLowerCase() === 'python' && spec.name) {
614614
// This should be our current python.
615615

616616
// Search for a digit on the end of the name. It should match our major version

src/client/datascience/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ export interface IJupyterExecution {
5252
}
5353

5454
export interface IJupyterKernelSpec extends Disposable {
55-
name: string;
56-
language: string;
57-
path: string;
55+
name: string | undefined;
56+
language: string | undefined;
57+
path: string | undefined;
5858
}
5959

6060
export const INotebookImporter = Symbol('INotebookImporter');

0 commit comments

Comments
 (0)