Skip to content

Commit a4d76a6

Browse files
committed
fix(microsoft-ad): allow $search+$filter combo, escape backslashes, fix pagination UX
Second independent 4-agent re-audit of the final state (post security fix) surfaced 3 more real issues: - list_users/list_groups threw an error whenever $search and $filter were both supplied, claiming Graph doesn't support combining them. It does (AND semantics, documented) — the check was blocking valid, documented usage for no reason. Removed it. - The $search term escaping only handled embedded double quotes, not backslashes, which Graph's own escaping rule also requires. Fixed the replace order (backslashes first, then quotes). - list_group_members's Group ID field was still hard-required in the block UI for every operation including list_group_members, undermining the nextLink-only pagination path added earlier (the tool itself no longer requires it). Dropped list_group_members from the UI-required list, matching the tool's own conditional requirement — the runtime "Group ID is required" check still catches a genuinely empty call.
1 parent 9e00f2d commit a4d76a6

3 files changed

Lines changed: 2 additions & 9 deletions

File tree

apps/sim/blocks/blocks/microsoft_ad.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ export const MicrosoftAdBlock: BlockConfig<MicrosoftAdResponse> = {
223223
'get_group',
224224
'update_group',
225225
'delete_group',
226-
'list_group_members',
227226
'add_group_member',
228227
'remove_group_member',
229228
],

apps/sim/tools/microsoft_ad/list_groups.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,9 @@ export const listGroupsTool: ToolConfig<
6060
'$select=id,displayName,description,mail,mailEnabled,mailNickname,securityEnabled,groupTypes,visibility,createdDateTime'
6161
)
6262
if (params.top) queryParts.push(`$top=${params.top}`)
63-
if (params.search && params.filter) {
64-
throw new Error('$search and $filter cannot be used together in Microsoft Graph API')
65-
}
6663
if (params.filter) queryParts.push(`$filter=${encodeURIComponent(params.filter)}`)
6764
if (params.search) {
68-
const term = params.search.replace(/"/g, '\\"')
65+
const term = params.search.replace(/\\/g, '\\\\').replace(/"/g, '\\"')
6966
queryParts.push(
7067
`$search=${encodeURIComponent(`"displayName:${term}" OR "description:${term}"`)}`
7168
)

apps/sim/tools/microsoft_ad/list_users.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,9 @@ export const listUsersTool: ToolConfig<MicrosoftAdListUsersParams, MicrosoftAdLi
5757
'$select=id,displayName,givenName,surname,userPrincipalName,mail,jobTitle,department,officeLocation,mobilePhone,accountEnabled'
5858
)
5959
if (params.top) queryParts.push(`$top=${params.top}`)
60-
if (params.search && params.filter) {
61-
throw new Error('$search and $filter cannot be used together in Microsoft Graph API')
62-
}
6360
if (params.filter) queryParts.push(`$filter=${encodeURIComponent(params.filter)}`)
6461
if (params.search) {
65-
const term = params.search.replace(/"/g, '\\"')
62+
const term = params.search.replace(/\\/g, '\\\\').replace(/"/g, '\\"')
6663
queryParts.push(`$search=${encodeURIComponent(`"displayName:${term}" OR "mail:${term}"`)}`)
6764
queryParts.push('$count=true')
6865
}

0 commit comments

Comments
 (0)