Skip to content

Commit f739046

Browse files
committed
fix(microsoft): address review — Outlook poller retries, SharePoint filter guard, opt-in Entra manager
1 parent 0824e0c commit f739046

19 files changed

Lines changed: 193 additions & 48 deletions

File tree

‎apps/docs/content/docs/integrations/azure_data_explorer.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Run a Kusto Query Language (KQL) query against an Azure Data Explorer database a
8080
| `records` | array | Result rows keyed by column name |
8181
| `rowCount` | number | Rows carried in this result, after the row cap |
8282
| `totalRowCount` | number | Rows Kusto returned, before the row cap was applied |
83-
| `truncated` | boolean | Whether rows were dropped to stay within the row or size cap — narrow the query if true |
83+
| `truncated` | boolean | Whether rows of the primary result table were dropped to stay within the row or size cap \(each additionalResults entry has its own truncated flag\) — narrow the query if true |
8484
| `additionalResults` | array | Further result tables, present only when a query batch \(statements separated by ;\) or fork returns more than one; the row and size caps are shared across all tables |
8585
| ↳ `tableName` | string | Result table name |
8686
| ↳ `columns` | array | Column metadata \(name, type, dataType\) |

‎apps/docs/content/docs/integrations/microsoft_ad.mdx‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,29 @@ Get a user by ID or user principal name from Azure AD
116116
| Parameter | Type | Description |
117117
| --------- | ---- | ----------- |
118118
| `user` | object | User details |
119+
| ↳ `id` | string | User ID |
120+
| ↳ `displayName` | string | Display name |
121+
| ↳ `givenName` | string | First name |
122+
| ↳ `surname` | string | Last name |
123+
| ↳ `userPrincipalName` | string | User principal name \(email\) |
124+
| ↳ `mail` | string | Email address |
125+
| ↳ `jobTitle` | string | Job title |
126+
| ↳ `department` | string | Department |
127+
| ↳ `officeLocation` | string | Office location |
128+
| ↳ `mobilePhone` | string | Mobile phone number |
129+
| ↳ `accountEnabled` | boolean | Whether the account is enabled |
130+
| ↳ `businessPhones` | array | Business phone numbers |
131+
| ↳ `preferredLanguage` | string | Preferred language |
132+
| ↳ `employeeId` | string | Employee identifier |
133+
| ↳ `employeeType` | string | Employee type \(e.g., Employee, Contractor\) |
134+
| ↳ `companyName` | string | Company name |
135+
| ↳ `userType` | string | User type: Member or Guest |
136+
| ↳ `usageLocation` | string | Two-letter country code, required before a license can be assigned |
137+
| ↳ `city` | string | City |
138+
| ↳ `country` | string | Country or region |
139+
| ↳ `createdDateTime` | string | When the user was created |
140+
| ↳ `onPremisesSyncEnabled` | boolean | Whether the user is synced from on-premises Active Directory |
141+
| `manager` | object | The user's manager, returned only when includeManager is true; null when no manager is assigned |
119142
| ↳ `id` | string | Manager object ID |
120143
| ↳ `displayName` | string | Manager display name |
121144
| ↳ `mail` | string | Manager email address |

‎apps/sim/blocks/blocks/azure_devops.ts‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,49 @@ export const AzureDevOpsBlock: BlockConfig = {
237237
condition: { field: 'operation', value: 'azure_devops_list_builds' },
238238
mode: 'advanced',
239239
},
240+
{
241+
id: 'reasonFilter',
242+
title: 'Build Reason',
243+
type: 'dropdown',
244+
options: [
245+
{ label: 'Any', id: '' },
246+
{ label: 'Manual', id: 'manual' },
247+
{ label: 'CI', id: 'individualCI' },
248+
{ label: 'Batched CI', id: 'batchedCI' },
249+
{ label: 'Schedule', id: 'schedule' },
250+
{ label: 'Pull Request', id: 'pullRequest' },
251+
{ label: 'Build Completion', id: 'buildCompletion' },
252+
{ label: 'Resource Trigger', id: 'resourceTrigger' },
253+
],
254+
value: () => '',
255+
condition: { field: 'operation', value: 'azure_devops_list_builds' },
256+
mode: 'advanced',
257+
},
258+
{
259+
id: 'requestedFor',
260+
title: 'Requested For',
261+
type: 'short-input',
262+
placeholder: 'User email or ID',
263+
condition: { field: 'operation', value: 'azure_devops_list_builds' },
264+
mode: 'advanced',
265+
},
266+
{
267+
id: 'queryOrder',
268+
title: 'Order',
269+
type: 'dropdown',
270+
options: [
271+
{ label: 'Default', id: '' },
272+
{ label: 'Queued (newest first)', id: 'queueTimeDescending' },
273+
{ label: 'Queued (oldest first)', id: 'queueTimeAscending' },
274+
{ label: 'Started (newest first)', id: 'startTimeDescending' },
275+
{ label: 'Started (oldest first)', id: 'startTimeAscending' },
276+
{ label: 'Finished (newest first)', id: 'finishTimeDescending' },
277+
{ label: 'Finished (oldest first)', id: 'finishTimeAscending' },
278+
],
279+
value: () => '',
280+
condition: { field: 'operation', value: 'azure_devops_list_builds' },
281+
mode: 'advanced',
282+
},
240283
{
241284
id: 'minTime',
242285
title: 'After',
@@ -662,6 +705,9 @@ export const AzureDevOpsBlock: BlockConfig = {
662705
definitionIds: (params.definitionIds as string) || undefined,
663706
statusFilter: (params.statusFilter as string) || undefined,
664707
branchName: (params.branchName as string) || undefined,
708+
reasonFilter: (params.reasonFilter as string) || undefined,
709+
requestedFor: (params.requestedFor as string) || undefined,
710+
queryOrder: (params.queryOrder as string) || undefined,
665711
minTime: normalizeDate(params.minTime),
666712
maxTime: normalizeDate(params.maxTime),
667713
continuationToken: (params.continuationToken as string) || undefined,
@@ -811,6 +857,9 @@ export const AzureDevOpsBlock: BlockConfig = {
811857
definitionIds: { type: 'string', description: 'Comma-separated pipeline definition IDs' },
812858
statusFilter: { type: 'string', description: 'Build status filter' },
813859
branchName: { type: 'string', description: 'Source branch filter (e.g. refs/heads/main)' },
860+
reasonFilter: { type: 'string', description: 'Build reason filter (list builds)' },
861+
requestedFor: { type: 'string', description: 'Requested-for user filter (list builds)' },
862+
queryOrder: { type: 'string', description: 'Build sort order (list builds)' },
814863
minTime: { type: 'string', description: 'Only builds after this ISO 8601 time' },
815864
maxTime: { type: 'string', description: 'Only builds before this ISO 8601 time' },
816865
continuationToken: { type: 'string', description: 'Continuation token for the next page' },

‎apps/sim/blocks/blocks/microsoft_ad.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -962,9 +962,13 @@ export const MicrosoftAdBlock: BlockConfig = {
962962
},
963963
userCount: { type: 'number', description: 'Number of users returned on this page' },
964964
user: {
965+
type: 'json',
966+
description: 'The single user this operation created or read',
967+
},
968+
manager: {
965969
type: 'json',
966970
description:
967-
'The single user this operation created or read. With Include Manager on, Get User also returns manager (id, displayName, mail, userPrincipalName, jobTitle), or null when none is assigned.',
971+
"Get User with Include Manager on: the user's manager (id, displayName, mail, userPrincipalName, jobTitle), or null when none is assigned",
968972
},
969973
userId: { type: 'string', description: 'Object ID of the user the operation acted on' },
970974
userPrincipalName: { type: 'string', description: 'User principal name of that user' },

‎apps/sim/blocks/blocks/microsoft_dataverse.ts‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -762,11 +762,7 @@ Return ONLY the expand expression - no $expand= prefix, no explanations.`,
762762
},
763763
outputs: {
764764
records: { type: 'json', description: 'Array of records (list/fetchxml/search)' },
765-
record: {
766-
type: 'json',
767-
description:
768-
'Single record data (update record returns it only when Return Updated Record is on)',
769-
},
765+
record: { type: 'json', description: 'Single record data' },
770766
recordId: { type: 'string', description: 'Record ID' },
771767
count: { type: 'number', description: 'Number of records returned in the current page' },
772768
totalCount: {

‎apps/sim/blocks/blocks/sharepoint.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,11 @@ export const SharepointV2Block: BlockConfig = {
12001200
title: 'Item Filter',
12011201
type: 'short-input',
12021202
placeholder: "OData filter, e.g. fields/Status eq 'Active'",
1203-
condition: { field: 'operation', value: 'sharepoint_get_list' },
1203+
condition: {
1204+
field: 'operation',
1205+
value: 'sharepoint_get_list',
1206+
and: { field: 'includeColumns', value: 'true', not: true },
1207+
},
12041208
mode: 'advanced',
12051209
wandConfig: {
12061210
enabled: true,
@@ -1222,7 +1226,11 @@ Return ONLY the filter expression - no explanations, no quotes around the whole
12221226
title: 'Items Per Page',
12231227
type: 'short-input',
12241228
placeholder: 'Maximum items per page (1-5000)',
1225-
condition: { field: 'operation', value: 'sharepoint_get_list' },
1229+
condition: {
1230+
field: 'operation',
1231+
value: 'sharepoint_get_list',
1232+
and: { field: 'includeColumns', value: 'true', not: true },
1233+
},
12261234
mode: 'advanced',
12271235
},
12281236
{

‎apps/sim/lib/internal/sharepoint/client.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getErrorMessage } from '@sim/utils/errors'
12
import {
23
type SecureFetchOptions,
34
type SecureFetchResponse,
@@ -79,9 +80,13 @@ function readJson<T>(
7980
}
8081

8182
function driveItemUrl(driveId: string, itemId: string): string {
82-
const drive = safeUrlPathSegment(driveId, 'driveId', { allowSeparators: true })
83-
const item = safeUrlPathSegment(itemId, 'itemId', { allowSeparators: true })
84-
return `https://graph.microsoft.com/v1.0/drives/${drive}/items/${item}`
83+
try {
84+
const drive = safeUrlPathSegment(driveId, 'driveId', { allowSeparators: true })
85+
const item = safeUrlPathSegment(itemId, 'itemId', { allowSeparators: true })
86+
return `https://graph.microsoft.com/v1.0/drives/${drive}/items/${item}`
87+
} catch (error) {
88+
throw new SharePointGraphError(getErrorMessage(error, 'Invalid drive item path'), 400)
89+
}
8590
}
8691

8792
function graphErrorMessage(

‎apps/sim/lib/internal/sharepoint/operations.ts‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,13 @@ export async function executeSharePointUploadFile(
131131
if (denied) return denied
132132

133133
const fileName = input.fileName || userFile.name
134+
let uploadUrls: { url: string; replaceUrl: string }
135+
try {
136+
uploadUrls = buildUploadUrl(input, fileName)
137+
} catch (error) {
138+
return failureResponse(getErrorMessage(error, 'Invalid upload path'), 400)
139+
}
140+
const { url, replaceUrl } = uploadUrls
134141
const skipOversized = (size: number) => {
135142
skippedFiles.push({
136143
name: fileName,
@@ -160,13 +167,6 @@ export async function executeSharePointUploadFile(
160167
throw error
161168
}
162169

163-
let uploadUrls: { url: string; replaceUrl: string }
164-
try {
165-
uploadUrls = buildUploadUrl(input, fileName)
166-
} catch (error) {
167-
return failureResponse(getErrorMessage(error, 'Invalid upload path'), 400)
168-
}
169-
const { url, replaceUrl } = uploadUrls
170170
const contentType = downloadedContentType || userFile.type || 'application/octet-stream'
171171
const uploadResult = await client.upload(url, buffer, contentType)
172172
if (!uploadResult.ok) {

‎apps/sim/lib/webhooks/polling/outlook.ts‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { getErrorMessage } from '@sim/utils/errors'
33
import { htmlToText } from 'html-to-text'
44
import { pollingIdempotency } from '@/lib/core/idempotency/service'
55
import { fetchWithRetry } from '@/lib/knowledge/documents/secure-fetch.server'
6+
import { AttachmentDownloadBudget } from '@/lib/uploads/utils/attachment-download-budget'
67
import {
78
getProviderConfig,
89
type PollingProviderHandler,
@@ -414,7 +415,21 @@ async function processOutlookEmails(
414415
let attachments: OutlookAttachment[] = []
415416
if (config.includeAttachments && email.hasAttachments) {
416417
try {
417-
attachments = await downloadAttachments(email.id, accessToken)
418+
attachments = await downloadAttachments(
419+
email.id,
420+
accessToken,
421+
new AttachmentDownloadBudget(),
422+
{
423+
fetchImpl: (url, init) => fetchWithRetry(url, init),
424+
keepPartialOnLimit: true,
425+
onFailure: (stage, status) =>
426+
logger.warn('Outlook attachment request failed', {
427+
emailId: email.id,
428+
stage,
429+
status,
430+
}),
431+
}
432+
)
418433
} catch (error) {
419434
logger.error(`Error downloading attachments for email ${email.id}:`, error)
420435
}

‎apps/sim/tools/azure_data_explorer/query.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export const azureDataExplorerQueryTool: InternalToolConfig<
144144
truncated: {
145145
type: 'boolean',
146146
description:
147-
'Whether rows were dropped to stay within the row or size cap — narrow the query if true',
147+
'Whether rows of the primary result table were dropped to stay within the row or size cap (each additionalResults entry has its own truncated flag) — narrow the query if true',
148148
},
149149
additionalResults: {
150150
type: 'array',

0 commit comments

Comments
 (0)