@devries-cameron20 / composio Mirror · read-only / commits / b5b6d4881
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, 13:15 UTC

fix: Add proper error handling for toolkit JSON loading

Sushmithamallesh committed Jan 27, 2026 at 22:37 UTC b5b6d4881112a6a42433eafda43e2c333d138428
1 file changed +22 -4
docs/app/sitemap.ts
+22 -4
@@ -17,12 +17,30 @@ interface Toolkit {
17 }
18
19 function getToolkitsFromJson(): Toolkit[] {
20 + const filePath = join(process.cwd(), 'public/data/toolkits.json');
21 +
22 try {
21 - const filePath = join(process.cwd(), 'public/data/toolkits.json');
23 const data = readFileSync(filePath, 'utf-8');
23 - return JSON.parse(data) as Toolkit[];
24 - } catch {
25 - return [];
24 + const toolkits = JSON.parse(data) as Toolkit[];
25 +
26 + if (!Array.isArray(toolkits)) {
27 + throw new Error('toolkits.json must contain an array');
28 + }
29 +
30 + if (toolkits.length === 0) {
31 + console.warn('[Sitemap] Warning: toolkits.json is empty - toolkit pages will be missing from sitemap');
32 + }
33 +
34 + return toolkits;
35 + } catch (error) {
36 + const err = error as NodeJS.ErrnoException;
37 + if (err.code === 'ENOENT') {
38 + throw new Error(`[Sitemap] Toolkits data file not found: ${filePath}`);
39 + }
40 + if (error instanceof SyntaxError) {
41 + throw new Error(`[Sitemap] Invalid JSON in toolkits.json: ${error.message}`);
42 + }
43 + throw error;
44 }
45 }
46