Skip to content

Commit

Permalink
handle error scenarios for validity check (#24393)
Browse files Browse the repository at this point in the history
  • Loading branch information
alanrenmsft authored and siyangMicrosoft committed Oct 12, 2023
1 parent aaf8d95 commit e87886e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/sql/workbench/browser/modelComponents/componentBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,16 @@ export abstract class ContainerBase<T, TPropertyBag extends azdata.ContainerProp
this._validations.push(() => {
this.logService.debug(`Running container validation on component ${this.descriptor.id} to check validity of all child items`);
return this.items.every(item => {
const valid = this.modelStore.getComponent(item.descriptor.id)?.valid;
const component = this.modelStore.getComponent(item.descriptor.id);
if (component === undefined) {
this.logService.warn(`Child item ${item.descriptor.id} of type ${item.descriptor.type} is undefined`);
} else if (component.valid === undefined) {
this.logService.warn(`The validity of child item ${item.descriptor.id} of type ${item.descriptor.type} undefined`);
}
// if the component is not found or the `valid` property is not set, we should treat it as valid.
const valid = component?.valid ?? true;
this.logService.debug(`Child item ${item.descriptor.id} validity is ${valid}`);
return valid || false;
return valid;
});
});
}
Expand Down

0 comments on commit e87886e

Please sign in to comment.