Skip to content

Commit edcee1d

Browse files
jsonbaileyclaude
andcommitted
fix: validate parameters and customParameters are objects before using
Add type guards for the parameters and customParameters fields in _parseToolsMap, consistent with existing guards on name, description, and type. Blind casts are replaced with null/object/array checks. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 12815aa commit edcee1d

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

packages/sdk/server-ai/src/api/config/LDAIConfigUtils.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,18 @@ export class LDAIConfigUtils {
162162
description:
163163
typeof toolObj['description'] === 'string' ? toolObj['description'] : undefined,
164164
type: typeof toolObj['type'] === 'string' ? toolObj['type'] : undefined,
165-
parameters: toolObj['parameters'] as LDTool['parameters'],
166-
customParameters: toolObj['customParameters'] as LDTool['customParameters'],
165+
parameters:
166+
toolObj['parameters'] !== null &&
167+
typeof toolObj['parameters'] === 'object' &&
168+
!Array.isArray(toolObj['parameters'])
169+
? (toolObj['parameters'] as LDTool['parameters'])
170+
: undefined,
171+
customParameters:
172+
toolObj['customParameters'] !== null &&
173+
typeof toolObj['customParameters'] === 'object' &&
174+
!Array.isArray(toolObj['customParameters'])
175+
? (toolObj['customParameters'] as LDTool['customParameters'])
176+
: undefined,
167177
};
168178
}
169179
return result;

0 commit comments

Comments
 (0)