@devries-cameron20 / composio-1 / commits / b0f5b358a
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.

Fix silent error handling in getToolkits - throw errors instead of returning empty array

Sushmithamallesh committed Jan 4, 2026 at 22:29 UTC b0f5b358ac3b43dd4051b1696e04e03a2cfb759d
1 file changed +22 -4
fumadocs/app/(home)/toolkits/[[...slug]]/page.tsx
+22 -4
@@ -9,12 +9,30 @@ import type { Metadata } from 'next';
9 import type { Toolkit } from '@/types/toolkit';
10
11 async function getToolkits(): Promise<Toolkit[]> {
12 + const filePath = join(process.cwd(), 'public/data/toolkits.json');
13 +
14 try {
13 - const filePath = join(process.cwd(), 'public/data/toolkits.json');
15 const data = await readFile(filePath, 'utf-8');
15 - return JSON.parse(data);
16 - } catch {
17 - return [];
16 + const toolkits = JSON.parse(data) as Toolkit[];
17 +
18 + if (!Array.isArray(toolkits)) {
19 + throw new Error('toolkits.json must contain an array');
20 + }
21 +
22 + if (toolkits.length === 0) {
23 + console.warn('[Toolkits] Warning: toolkits.json is empty');
24 + }
25 +
26 + return toolkits;
27 + } catch (error) {
28 + const err = error as NodeJS.ErrnoException;
29 + if (err.code === 'ENOENT') {
30 + throw new Error(`Toolkits data file not found: ${filePath}`);
31 + }
32 + if (error instanceof SyntaxError) {
33 + throw new Error(`Invalid JSON in toolkits.json: ${error.message}`);
34 + }
35 + throw error;
36 }
37 }
38