Skip to content

Commit 8c84970

Browse files
committed
fix(integrations): normalize outlook categories input and clamp notion pageSize
- outlook: normalize update_message categories (array, JSON string, or comma/newline) so a JSON-string value isn't silently dropped - notion: clamp pageSize to Notion's 1-100 range (truncated) so out-of-range values don't hit an API error
1 parent 3f16505 commit 8c84970

2 files changed

Lines changed: 27 additions & 5 deletions

File tree

apps/sim/blocks/blocks/notion.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,9 @@ export const NotionBlock: BlockConfig<NotionResponse> = {
595595
let coercedPageSize: number | undefined
596596
if (pageSize !== undefined && pageSize !== null && pageSize !== '') {
597597
const parsedPageSize = Number(pageSize)
598-
if (Number.isFinite(parsedPageSize)) coercedPageSize = parsedPageSize
598+
if (Number.isFinite(parsedPageSize)) {
599+
coercedPageSize = Math.min(Math.max(Math.trunc(parsedPageSize), 1), 100)
600+
}
599601
}
600602

601603
return {

apps/sim/tools/outlook/update_message.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,27 @@ interface OutlookMessageUpdateApi {
1313
isRead?: boolean
1414
}
1515

16+
/**
17+
* Normalize message categories into a trimmed string array. Accepts an array, a
18+
* JSON-array string, or a comma/newline-separated string (the `json`-typed param
19+
* can arrive in any of these forms from block inputs or agent tool-calls).
20+
*/
21+
function normalizeCategories(value: unknown): string[] {
22+
let items: unknown[] = []
23+
if (Array.isArray(value)) {
24+
items = value
25+
} else if (typeof value === 'string') {
26+
const trimmed = value.trim()
27+
try {
28+
const parsed = JSON.parse(trimmed)
29+
items = Array.isArray(parsed) ? parsed : trimmed.split(/[,\n]/)
30+
} catch {
31+
items = trimmed.split(/[,\n]/)
32+
}
33+
}
34+
return items.map((item) => String(item).trim()).filter(Boolean)
35+
}
36+
1637
export const outlookUpdateMessageTool: ToolConfig<
1738
OutlookUpdateMessageParams,
1839
OutlookUpdateMessageResponse
@@ -76,10 +97,9 @@ export const outlookUpdateMessageTool: ToolConfig<
7697
body: (params) => {
7798
const body: Record<string, unknown> = {}
7899

79-
if (Array.isArray(params.categories)) {
80-
body.categories = params.categories
81-
.map((category) => String(category).trim())
82-
.filter((category) => category.length > 0)
100+
const categories = normalizeCategories(params.categories)
101+
if (categories.length > 0) {
102+
body.categories = categories
83103
}
84104

85105
if (params.flagStatus) {

0 commit comments

Comments
 (0)