From eafec4fad9a394e78208082bdd9dc80eafe818c0 Mon Sep 17 00:00:00 2001 From: Vikhyath Mondreti Date: Sat, 10 Jan 2026 11:19:44 -0800 Subject: [PATCH] fix(perms): copilot checks undefined issue --- apps/sim/lib/copilot/process-contents.ts | 2 +- apps/sim/lib/copilot/tools/server/blocks/get-block-config.ts | 2 +- apps/sim/lib/copilot/tools/server/blocks/get-block-options.ts | 2 +- .../sim/lib/copilot/tools/server/blocks/get-blocks-and-tools.ts | 2 +- .../lib/copilot/tools/server/blocks/get-blocks-metadata-tool.ts | 2 +- apps/sim/lib/copilot/tools/server/blocks/get-trigger-blocks.ts | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/sim/lib/copilot/process-contents.ts b/apps/sim/lib/copilot/process-contents.ts index ccb690964e..3b62b9197c 100644 --- a/apps/sim/lib/copilot/process-contents.ts +++ b/apps/sim/lib/copilot/process-contents.ts @@ -369,7 +369,7 @@ async function processBlockMetadata( if (userId) { const permissionConfig = await getUserPermissionConfig(userId) const allowedIntegrations = permissionConfig?.allowedIntegrations - if (allowedIntegrations !== null && !allowedIntegrations?.includes(blockId)) { + if (allowedIntegrations != null && !allowedIntegrations.includes(blockId)) { logger.debug('Block not allowed by permission group', { blockId, userId }) return null } diff --git a/apps/sim/lib/copilot/tools/server/blocks/get-block-config.ts b/apps/sim/lib/copilot/tools/server/blocks/get-block-config.ts index 77c9446bdf..6188e72812 100644 --- a/apps/sim/lib/copilot/tools/server/blocks/get-block-config.ts +++ b/apps/sim/lib/copilot/tools/server/blocks/get-block-config.ts @@ -309,7 +309,7 @@ export const getBlockConfigServerTool: BaseServerTool< const permissionConfig = context?.userId ? await getUserPermissionConfig(context.userId) : null const allowedIntegrations = permissionConfig?.allowedIntegrations - if (allowedIntegrations !== null && !allowedIntegrations?.includes(blockType)) { + if (allowedIntegrations != null && !allowedIntegrations.includes(blockType)) { throw new Error(`Block "${blockType}" is not available`) } diff --git a/apps/sim/lib/copilot/tools/server/blocks/get-block-options.ts b/apps/sim/lib/copilot/tools/server/blocks/get-block-options.ts index 9898b11c21..595371b0da 100644 --- a/apps/sim/lib/copilot/tools/server/blocks/get-block-options.ts +++ b/apps/sim/lib/copilot/tools/server/blocks/get-block-options.ts @@ -24,7 +24,7 @@ export const getBlockOptionsServerTool: BaseServerTool< const permissionConfig = context?.userId ? await getUserPermissionConfig(context.userId) : null const allowedIntegrations = permissionConfig?.allowedIntegrations - if (allowedIntegrations !== null && !allowedIntegrations?.includes(blockId)) { + if (allowedIntegrations != null && !allowedIntegrations.includes(blockId)) { throw new Error(`Block "${blockId}" is not available`) } diff --git a/apps/sim/lib/copilot/tools/server/blocks/get-blocks-and-tools.ts b/apps/sim/lib/copilot/tools/server/blocks/get-blocks-and-tools.ts index 48851448dd..222288aabc 100644 --- a/apps/sim/lib/copilot/tools/server/blocks/get-blocks-and-tools.ts +++ b/apps/sim/lib/copilot/tools/server/blocks/get-blocks-and-tools.ts @@ -31,7 +31,7 @@ export const getBlocksAndToolsServerTool: BaseServerTool< Object.entries(blockRegistry) .filter(([blockType, blockConfig]: [string, BlockConfig]) => { if (blockConfig.hideFromToolbar) return false - if (allowedIntegrations !== null && !allowedIntegrations?.includes(blockType)) return false + if (allowedIntegrations != null && !allowedIntegrations.includes(blockType)) return false return true }) .forEach(([blockType, blockConfig]: [string, BlockConfig]) => { diff --git a/apps/sim/lib/copilot/tools/server/blocks/get-blocks-metadata-tool.ts b/apps/sim/lib/copilot/tools/server/blocks/get-blocks-metadata-tool.ts index ffaa05b696..35cad8d465 100644 --- a/apps/sim/lib/copilot/tools/server/blocks/get-blocks-metadata-tool.ts +++ b/apps/sim/lib/copilot/tools/server/blocks/get-blocks-metadata-tool.ts @@ -118,7 +118,7 @@ export const getBlocksMetadataServerTool: BaseServerTool< const result: Record = {} for (const blockId of blockIds || []) { - if (allowedIntegrations !== null && !allowedIntegrations?.includes(blockId)) { + if (allowedIntegrations != null && !allowedIntegrations.includes(blockId)) { logger.debug('Block not allowed by permission group', { blockId }) continue } diff --git a/apps/sim/lib/copilot/tools/server/blocks/get-trigger-blocks.ts b/apps/sim/lib/copilot/tools/server/blocks/get-trigger-blocks.ts index 3e6f84ed25..c5f3b75b4f 100644 --- a/apps/sim/lib/copilot/tools/server/blocks/get-trigger-blocks.ts +++ b/apps/sim/lib/copilot/tools/server/blocks/get-trigger-blocks.ts @@ -26,7 +26,7 @@ export const getTriggerBlocksServerTool: BaseServerTool< Object.entries(blockRegistry).forEach(([blockType, blockConfig]: [string, BlockConfig]) => { if (blockConfig.hideFromToolbar) return - if (allowedIntegrations !== null && !allowedIntegrations?.includes(blockType)) return + if (allowedIntegrations != null && !allowedIntegrations.includes(blockType)) return if (blockConfig.category === 'triggers') { triggerBlockIds.push(blockType)