Skip to content

Commit 62e8794

Browse files
committed
Refactor null-safe checks in ToolFinder.ts
Ensure safer access to nested properties in `uischema` by incorporating optional chaining. This change guards against potential runtime errors when `uischema` is undefined.
1 parent 65dbf02 commit 62e8794

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/lib/ToolFinder.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,11 @@ export class ToolFinder implements ToolFinderInterface {
202202

203203
const hasSchema = _.isObject(tool.schema);
204204
const hasUischema = _.isObject(tool.uischema);
205-
const hasUischemaType = hasUischema && tool.uischema.type;
205+
const hasUischemaType = hasUischema && tool.uischema?.type;
206206
const hasElements = hasUischemaType && 'elements' in tool.uischema;
207207
const isScoped = hasUischemaType && 'scope' in tool.uischema;
208-
const isAutoLayout = isScoped && tool.uischema.scope === '#'; //:TODO are there other scopes?
209-
const isLabel = tool.uischema.type === 'Label';
208+
const isAutoLayout = isScoped && tool.uischema?.scope === '#'; //:TODO are there other scopes?
209+
const isLabel = hasUischemaType && tool.uischema?.type === 'Label';
210210

211211
const isLayout = !hasSchema || (hasElements) || isLabel || isAutoLayout;
212212

0 commit comments

Comments
 (0)