diff --git a/src/sql/workbench/services/notebook/browser/models/notebookModel.ts b/src/sql/workbench/services/notebook/browser/models/notebookModel.ts index 8aaa3f9dbd..655997ad4d 100644 --- a/src/sql/workbench/services/notebook/browser/models/notebookModel.ts +++ b/src/sql/workbench/services/notebook/browser/models/notebookModel.ts @@ -653,9 +653,12 @@ export class NotebookModel extends Disposable implements INotebookModel { let standardKernels = find(this._standardKernels, kernel => this._defaultKernel && kernel.displayName === this._defaultKernel.display_name); let connectionProviderIds = standardKernels ? standardKernels.connectionProviderIds : undefined; let providerFeatures = this._capabilitiesService.getCapabilities(profile.providerName); - if (connectionProviderIds.length > 0 && this._currentKernelAlias) { + if (connectionProviderIds?.length) { this._currentKernelAlias = providerFeatures?.connection.notebookKernelAlias; - this._kernelDisplayNameToConnectionProviderIds.set(this._currentKernelAlias, [profile.providerName]); + // Adds Kernel Alias and Connection Provider to Map if new Notebook connection contains notebookKernelAlias + if (this._currentKernelAlias) { + this._kernelDisplayNameToConnectionProviderIds.set(this._currentKernelAlias, [profile.providerName]); + } } return this._currentKernelAlias || profile && connectionProviderIds && find(connectionProviderIds, provider => provider === profile.providerName) !== undefined; }