diff --git a/src/sql/workbench/services/objectExplorer/browser/serverTreeDataSource.ts b/src/sql/workbench/services/objectExplorer/browser/serverTreeDataSource.ts index e7a4d27f1a..ebcbdb6876 100644 --- a/src/sql/workbench/services/objectExplorer/browser/serverTreeDataSource.ts +++ b/src/sql/workbench/services/objectExplorer/browser/serverTreeDataSource.ts @@ -29,8 +29,13 @@ export class ServerTreeDataSource implements IDataSource { * Returns the unique identifier of the given element. * No more than one element may use a given identifier. */ - public getId(tree: ITree, element: any): string { - return element.id; + public getId(tree: ITree, element?: any): string { + // Note there really shouldn't be any undefined elements in the tree, but the original implementation + // didn't do that correctly and since this is going to replaced by the async tree at some point just + // making it so we handle the undefined case here. + // This should be safe to do since the undefined element is only used when we want to clear the tree + // so it'll be the only "element" in the tree and thus there shouldn't be any duplicate ids + return element?.id || ''; } /**