Skip to content

Commit a2d4a83

Browse files
committed
fix(integrations): clamp twilio voice page size, mark discord user avatar nullable
1 parent 464f99c commit a2d4a83

3 files changed

Lines changed: 21 additions & 2 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export const discordGetUserTool: ToolConfig<DiscordGetUserParams, DiscordGetUser
7373
optional: true,
7474
nullable: true,
7575
},
76-
avatar: { type: 'string', description: 'User avatar hash', optional: true },
76+
avatar: { type: 'string', description: 'User avatar hash', optional: true, nullable: true },
7777
bot: { type: 'boolean', description: 'Whether user is a bot' },
7878
system: { type: 'boolean', description: 'Whether user is a system user' },
7979
email: {

‎apps/sim/tools/twilio_voice/list_calls.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,19 @@ describe('Twilio list calls pagination', () => {
123123
expect(result.output.nextPageToken).toBe('PA2')
124124
})
125125
})
126+
127+
describe('Twilio list calls page size', () => {
128+
function pageSizeSent(pageSize: number): string | null {
129+
const url = listCallsTool.request.url
130+
if (typeof url !== 'function') throw new Error('Expected a URL builder')
131+
return new URL(url({ accountSid: 'AC123', authToken: 'secret', pageSize })).searchParams.get(
132+
'PageSize'
133+
)
134+
}
135+
136+
it('clamps PageSize to the 1-1000 integer range Twilio accepts', () => {
137+
expect(pageSizeSent(5000)).toBe('1000')
138+
expect(pageSizeSent(-3)).toBe('1')
139+
expect(pageSizeSent(20.9)).toBe('20')
140+
})
141+
})

‎apps/sim/tools/twilio_voice/list_calls.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ export const listCallsTool: ToolConfig<TwilioListCallsParams, TwilioListCallsOut
134134
if (params.status) queryParams.append('Status', params.status)
135135
if (params.startTimeAfter) queryParams.append('StartTime>', params.startTimeAfter)
136136
if (params.startTimeBefore) queryParams.append('StartTime<', params.startTimeBefore)
137-
if (params.pageSize) queryParams.append('PageSize', Number(params.pageSize).toString())
137+
const pageSize = Math.trunc(Number(params.pageSize))
138+
if (pageSize && Number.isFinite(pageSize)) {
139+
queryParams.append('PageSize', String(Math.min(Math.max(1, pageSize), 1000)))
140+
}
138141
if (params.pageToken) queryParams.append('PageToken', params.pageToken)
139142

140143
const queryString = queryParams.toString()

0 commit comments

Comments
 (0)