diff --git a/src/sql/workbench/services/connection/browser/connectionManagementService.ts b/src/sql/workbench/services/connection/browser/connectionManagementService.ts index 534f145cea..845d406024 100644 --- a/src/sql/workbench/services/connection/browser/connectionManagementService.ts +++ b/src/sql/workbench/services/connection/browser/connectionManagementService.ts @@ -1372,7 +1372,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti return credentials; } - public getServerInfo(profileId: string): azdata.ServerInfo { + public getServerInfo(profileId: string): azdata.ServerInfo | undefined { let profile = this._connectionStatusManager.findConnectionByProfileId(profileId); if (!profile) { return undefined; diff --git a/src/sql/workbench/services/objectExplorer/browser/serverTreeActionProvider.ts b/src/sql/workbench/services/objectExplorer/browser/serverTreeActionProvider.ts index 5e785ba9ca..1439b6f1b1 100644 --- a/src/sql/workbench/services/objectExplorer/browser/serverTreeActionProvider.ts +++ b/src/sql/workbench/services/objectExplorer/browser/serverTreeActionProvider.ts @@ -143,7 +143,9 @@ export class ServerTreeActionProvider { let serverInfoContextKey = new ServerInfoContextKey(scopedContextService); if (connectionProfile.id) { let serverInfo = this._connectionManagementService.getServerInfo(connectionProfile.id); - serverInfoContextKey.set(serverInfo); + if (serverInfo) { + serverInfoContextKey.set(serverInfo); + } } let treeNodeContextKey = new TreeNodeContextKey(scopedContextService); if (context.treeNode) {