@devries-cameron20 / composio Mirror · read-only / commits / 32b5e38b1
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 22, 10:45 UTC

fix(docs): prevent infinite recursion in isExpandable on circular refs

Add visited Set to track already-processed schema types and prevent infinite recursion when checking if oneOf/anyOf/array schemas with circular references are expandable. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Sushmithamallesh committed Feb 4, 2026 at 14:20 UTC 32b5e38b1e8beee3dfce9968ba3b59be228d15b8
1 file changed +11 -3
docs/components/custom-schema-ui.tsx
+11 -3
@@ -235,12 +235,18 @@ function ExpandableContent({
235 );
236 }
237
238 -function isExpandable(schema: SchemaData, refs?: Record<string, SchemaData>): boolean {
238 +function isExpandable(
239 + schema: SchemaData,
240 + refs?: Record<string, SchemaData>,
241 + visited: Set<string> = new Set()
242 +): boolean {
243 if (schema.type === 'object' && schema.props.length > 0) return true;
244 if (schema.type === 'array') {
245 // Only expandable if items have structure (object/nested)
246 if (!refs) return true;
243 - const itemSchema = refs[schema.item.$type];
247 + const itemType = schema.item.$type;
248 + if (visited.has(itemType)) return false; // Circular ref - not expandable
249 + const itemSchema = refs[itemType];
250 if (!itemSchema) return true;
251 return itemSchema.type !== 'primitive';
252 }
@@ -248,9 +254,11 @@ function isExpandable(schema: SchemaData, refs?: Record<string, SchemaData>): bo
254 // Only expandable if at least one variant has nested structure
255 if (!refs) return true;
256 return schema.items.some((item) => {
257 + if (visited.has(item.$type)) return false; // Circular ref - not expandable
258 const itemSchema = refs[item.$type];
259 if (!itemSchema) return false;
253 - return isExpandable(itemSchema, refs);
260 + visited.add(item.$type);
261 + return isExpandable(itemSchema, refs, visited);
262 });
263 }
264 return false;