Skip to content

Commit 92fabe7

Browse files
fix(perms): copilot checks undefined issue (#2763)
1 parent 3ed1775 commit 92fabe7

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

apps/sim/lib/copilot/process-contents.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ async function processBlockMetadata(
369369
if (userId) {
370370
const permissionConfig = await getUserPermissionConfig(userId)
371371
const allowedIntegrations = permissionConfig?.allowedIntegrations
372-
if (allowedIntegrations !== null && !allowedIntegrations?.includes(blockId)) {
372+
if (allowedIntegrations != null && !allowedIntegrations.includes(blockId)) {
373373
logger.debug('Block not allowed by permission group', { blockId, userId })
374374
return null
375375
}

apps/sim/lib/copilot/tools/server/blocks/get-block-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ export const getBlockConfigServerTool: BaseServerTool<
309309
const permissionConfig = context?.userId ? await getUserPermissionConfig(context.userId) : null
310310
const allowedIntegrations = permissionConfig?.allowedIntegrations
311311

312-
if (allowedIntegrations !== null && !allowedIntegrations?.includes(blockType)) {
312+
if (allowedIntegrations != null && !allowedIntegrations.includes(blockType)) {
313313
throw new Error(`Block "${blockType}" is not available`)
314314
}
315315

apps/sim/lib/copilot/tools/server/blocks/get-block-options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const getBlockOptionsServerTool: BaseServerTool<
2424
const permissionConfig = context?.userId ? await getUserPermissionConfig(context.userId) : null
2525
const allowedIntegrations = permissionConfig?.allowedIntegrations
2626

27-
if (allowedIntegrations !== null && !allowedIntegrations?.includes(blockId)) {
27+
if (allowedIntegrations != null && !allowedIntegrations.includes(blockId)) {
2828
throw new Error(`Block "${blockId}" is not available`)
2929
}
3030

apps/sim/lib/copilot/tools/server/blocks/get-blocks-and-tools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const getBlocksAndToolsServerTool: BaseServerTool<
3131
Object.entries(blockRegistry)
3232
.filter(([blockType, blockConfig]: [string, BlockConfig]) => {
3333
if (blockConfig.hideFromToolbar) return false
34-
if (allowedIntegrations !== null && !allowedIntegrations?.includes(blockType)) return false
34+
if (allowedIntegrations != null && !allowedIntegrations.includes(blockType)) return false
3535
return true
3636
})
3737
.forEach(([blockType, blockConfig]: [string, BlockConfig]) => {

apps/sim/lib/copilot/tools/server/blocks/get-blocks-metadata-tool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export const getBlocksMetadataServerTool: BaseServerTool<
118118

119119
const result: Record<string, CopilotBlockMetadata> = {}
120120
for (const blockId of blockIds || []) {
121-
if (allowedIntegrations !== null && !allowedIntegrations?.includes(blockId)) {
121+
if (allowedIntegrations != null && !allowedIntegrations.includes(blockId)) {
122122
logger.debug('Block not allowed by permission group', { blockId })
123123
continue
124124
}

apps/sim/lib/copilot/tools/server/blocks/get-trigger-blocks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const getTriggerBlocksServerTool: BaseServerTool<
2626

2727
Object.entries(blockRegistry).forEach(([blockType, blockConfig]: [string, BlockConfig]) => {
2828
if (blockConfig.hideFromToolbar) return
29-
if (allowedIntegrations !== null && !allowedIntegrations?.includes(blockType)) return
29+
if (allowedIntegrations != null && !allowedIntegrations.includes(blockType)) return
3030

3131
if (blockConfig.category === 'triggers') {
3232
triggerBlockIds.push(blockType)

0 commit comments

Comments
 (0)