Skip to content

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: Add proper error handling for toolkit JSON loading

Sushmithamalleshb5b6d4881112
diff --git a/docs/app/sitemap.ts b/docs/app/sitemap.ts
index 25d60c15b..b80ff4538 100644
--- a/docs/app/sitemap.ts
+++ b/docs/app/sitemap.ts
@@ -17,12 +17,30 @@ interface Toolkit {
}
function getToolkitsFromJson(): Toolkit[] {
+ const filePath = join(process.cwd(), 'public/data/toolkits.json');
+
try {
- const filePath = join(process.cwd(), 'public/data/toolkits.json');
const data = readFileSync(filePath, 'utf-8');
- return JSON.parse(data) as Toolkit[];
- } catch {
- return [];
+ const toolkits = JSON.parse(data) as Toolkit[];
+
+ if (!Array.isArray(toolkits)) {
+ throw new Error('toolkits.json must contain an array');
+ }
+
+ if (toolkits.length === 0) {
+ console.warn('[Sitemap] Warning: toolkits.json is empty - toolkit pages will be missing from sitemap');
+ }
+
+ return toolkits;
+ } catch (error) {
+ const err = error as NodeJS.ErrnoException;
+ if (err.code === 'ENOENT') {
+ throw new Error(`[Sitemap] Toolkits data file not found: ${filePath}`);
+ }
+ if (error instanceof SyntaxError) {
+ throw new Error(`[Sitemap] Invalid JSON in toolkits.json: ${error.message}`);
+ }
+ throw error;
}
}