Skip to content

Commit 464f99c

Browse files
committed
fix(integrations): address v3 review findings
- twilio: trim account SID and From number once, mark sender/recipient outputs nullable, make From optional on the block when a Messaging Service is used - discord: truncate fractional limits, reject more than one message cursor, mark nullable outputs - telegram: only keep spoiler spans, drop NUL so input cannot alias a protected segment, mark optional animation fields, fall back to model poll options when the stored field is blank - resend: clamp list limit to 1-100, sentence covers segment or audience, nullable broadcast outputs - mailgun: clamp events limit to 300 - twilio voice: nextPageToken nullable - fix test-types errors in twilio and whatsapp tests
1 parent dd73880 commit 464f99c

19 files changed

Lines changed: 107 additions & 37 deletions

‎apps/sim/blocks/blocks/resend.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const ResendBlock: BlockConfig = {
4040
delete_audience: [{ text: 'Delete audience', field: 'audienceId', core: true }],
4141
create_broadcast: [
4242
'Draft a broadcast',
43-
{ text: 'for audience', field: 'audienceId', core: true },
43+
{ text: 'for', field: ['segmentId', 'audienceId'], core: true },
4444
{ text: ', subject', field: 'broadcastSubject' },
4545
{ text: ', named', field: 'broadcastName' },
4646
],

‎apps/sim/blocks/blocks/telegram.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ function telegramToolParams(
198198
const pollParams: Record<string, unknown> = {
199199
...commonParams,
200200
question: params.question,
201-
options: params.pollOptions ?? toolCallArg(context, params.options),
201+
options: params.pollOptions || toolCallArg(context, params.options),
202202
}
203203
if (params.isAnonymous !== undefined && params.isAnonymous !== '') {
204204
pollParams.isAnonymous = toBoolean(params.isAnonymous)

‎apps/sim/blocks/blocks/twilio.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ export const TwilioSMSBlock: BlockConfig = {
7474
id: 'fromNumber',
7575
title: 'From Twilio Phone Number',
7676
type: 'short-input',
77-
placeholder: 'e.g. +1234567890',
78-
required: true,
77+
placeholder: 'e.g. +1234567890 (optional with a Messaging Service SID)',
7978
},
8079
{
8180
id: 'messagingServiceSid',

‎apps/sim/tools/discord/edit_message.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export const discordEditMessageTool: ToolConfig<
8888
type: 'string',
8989
description: 'Message edited timestamp',
9090
optional: true,
91+
nullable: true,
9192
},
9293
},
9394
},

‎apps/sim/tools/discord/get_channel.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export const discordGetChannelTool: ToolConfig<DiscordGetChannelParams, DiscordG
6262
id: { type: 'string', description: 'Channel ID' },
6363
name: { type: 'string', description: 'Channel name' },
6464
type: { type: 'number', description: 'Channel type' },
65-
topic: { type: 'string', description: 'Channel topic', optional: true },
65+
topic: { type: 'string', description: 'Channel topic', optional: true, nullable: true },
6666
guild_id: { type: 'string', description: 'Server ID' },
6767
},
6868
},

‎apps/sim/tools/discord/get_member.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ export const discordGetMemberTool: ToolConfig<DiscordGetMemberParams, DiscordGet
6464
properties: {
6565
id: { type: 'string', description: 'User ID' },
6666
username: { type: 'string', description: 'Username' },
67-
avatar: { type: 'string', description: 'Avatar hash', optional: true },
67+
avatar: { type: 'string', description: 'Avatar hash', optional: true, nullable: true },
6868
},
6969
},
70-
nick: { type: 'string', description: 'Server nickname', optional: true },
70+
nick: { type: 'string', description: 'Server nickname', optional: true, nullable: true },
7171
roles: { type: 'array', description: 'Array of role IDs' },
7272
joined_at: { type: 'string', description: 'When the member joined' },
7373
},

‎apps/sim/tools/discord/get_messages.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,17 @@ export const discordGetMessagesTool: ToolConfig<
5656

5757
request: {
5858
url: (params: DiscordGetMessagesParams) => {
59-
const requested = Number(params.limit)
59+
const requested = Math.trunc(Number(params.limit))
6060
const limit = requested && Number.isFinite(requested) ? requested : 10
6161
const query = new URLSearchParams({ limit: String(Math.min(Math.max(1, limit), 100)) })
62-
for (const cursor of ['before', 'after', 'around'] as const) {
62+
const cursors = (['before', 'after', 'around'] as const).flatMap((cursor) => {
6363
const value = String(params[cursor] ?? '').trim()
64-
if (value) query.set(cursor, value)
64+
return value ? [[cursor, value] as const] : []
65+
})
66+
if (cursors.length > 1) {
67+
throw new Error('Use only one of before, after, or around')
6568
}
69+
for (const [cursor, value] of cursors) query.set(cursor, value)
6670
return `https://discord.com/api/v10/channels/${safeUrlPathSegment(params.channelId, 'channelId')}/messages?${query.toString()}`
6771
},
6872
method: 'GET',
@@ -121,6 +125,7 @@ export const discordGetMessagesTool: ToolConfig<
121125
type: 'string',
122126
description: 'Message edited timestamp',
123127
optional: true,
128+
nullable: true,
124129
},
125130
embeds: { type: 'array', description: 'Message embeds' },
126131
attachments: { type: 'array', description: 'Message attachments' },

‎apps/sim/tools/discord/get_user.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export const discordGetUserTool: ToolConfig<DiscordGetUserParams, DiscordGetUser
7171
type: 'string',
7272
description: 'User display name, if set',
7373
optional: true,
74+
nullable: true,
7475
},
7576
avatar: { type: 'string', description: 'User avatar hash', optional: true },
7677
bot: { type: 'boolean', description: 'Whether user is a bot' },

‎apps/sim/tools/mailgun/list_messages.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ export const mailgunListMessagesTool: ToolConfig<ListMessagesParams, ListMessage
5151
if (params.event) {
5252
queryParams.append('event', params.event)
5353
}
54-
if (params.limit) {
55-
queryParams.append('limit', params.limit.toString())
54+
const limit = Math.trunc(Number(params.limit))
55+
if (limit && Number.isFinite(limit)) {
56+
queryParams.append('limit', String(Math.min(Math.max(1, limit), 300)))
5657
}
5758

5859
const query = queryParams.toString()

‎apps/sim/tools/resend/get_broadcast.ts‎

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,17 @@ export const resendGetBroadcastTool: ToolConfig<GetBroadcastParams, GetBroadcast
8484
outputs: {
8585
id: { type: 'string', description: 'Broadcast ID' },
8686
name: { type: 'string', description: 'Broadcast name' },
87-
audienceId: { type: 'string', description: 'Audience ID (legacy)', optional: true },
87+
audienceId: {
88+
type: 'string',
89+
description: 'Audience ID (legacy)',
90+
optional: true,
91+
nullable: true,
92+
},
8893
segmentId: {
8994
type: 'string',
9095
description: 'Segment ID (the current recipient field)',
9196
optional: true,
97+
nullable: true,
9298
},
9399
from: { type: 'string', description: 'Sender email address' },
94100
subject: { type: 'string', description: 'Broadcast subject' },
@@ -97,11 +103,27 @@ export const resendGetBroadcastTool: ToolConfig<GetBroadcastParams, GetBroadcast
97103
description: 'Reply-to email addresses',
98104
items: { type: 'string', description: 'Reply-to email address' },
99105
optional: true,
106+
nullable: true,
107+
},
108+
previewText: {
109+
type: 'string',
110+
description: 'Inbox preview text',
111+
optional: true,
112+
nullable: true,
100113
},
101-
previewText: { type: 'string', description: 'Inbox preview text', optional: true },
102114
status: { type: 'string', description: 'Broadcast status (e.g., draft, sent)' },
103115
createdAt: { type: 'string', description: 'Broadcast creation timestamp' },
104-
scheduledAt: { type: 'string', description: 'Scheduled send timestamp', optional: true },
105-
sentAt: { type: 'string', description: 'Timestamp the broadcast was sent', optional: true },
116+
scheduledAt: {
117+
type: 'string',
118+
description: 'Scheduled send timestamp',
119+
optional: true,
120+
nullable: true,
121+
},
122+
sentAt: {
123+
type: 'string',
124+
description: 'Timestamp the broadcast was sent',
125+
optional: true,
126+
nullable: true,
127+
},
106128
},
107129
}

0 commit comments

Comments
 (0)