Skip to content

Commit e5cbc17

Browse files
authored
fix(integrations): address release review findings on the sweep (#10098)
* fix(integrations): address release review findings on the sweep * fix(resend): keep the catalog's audience requirement static and type the new tests
1 parent efb4054 commit e5cbc17

13 files changed

Lines changed: 455 additions & 206 deletions

File tree

‎apps/sim/blocks/blocks/affinity.test.ts‎

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1-
import { describe, expect, it } from 'vitest'
1+
import { describe, expect, it, vi } from 'vitest'
2+
3+
vi.mock('@/lib/internal/workflows/read-tool-enrichment', () => ({
4+
readWorkflowInputFieldsForTool: vi.fn(),
5+
readWorkflowMetadataForTool: vi.fn(),
6+
}))
7+
28
import { AffinityBlock } from '@/blocks/blocks/affinity'
9+
import { ToolCallParamsError } from '@/providers/tool-params-error'
10+
import { prepareToolExecution, transformBlockTool } from '@/providers/utils'
11+
import { affinityCreateListFieldDropdownOptionTool } from '@/tools/affinity/create_list_field_dropdown_option'
312

413
/** Runs the mapper the way an Agent tool call does: its result is spread over the merged args. */
514
function toolCall(args: Record<string, unknown>, operation: string) {
@@ -22,3 +31,49 @@ describe('AffinityBlock agent tool calls', () => {
2231
).toMatchObject({ name: 'Deals', type: 'company', isPublic: true })
2332
})
2433
})
34+
35+
describe('AffinityBlock dropdown option rank and win rate on a tool call', () => {
36+
const operation = 'create_list_field_dropdown_option'
37+
38+
async function prepare(stored: Record<string, string>, modelArgs: Record<string, unknown>) {
39+
const providerTool = await transformBlockTool(
40+
{ type: AffinityBlock.type, operation, params: { apiKey: 'key', ...stored } },
41+
{
42+
selectedOperation: operation,
43+
getAllBlocks: () => [AffinityBlock],
44+
getTool: () => affinityCreateListFieldDropdownOptionTool,
45+
}
46+
)
47+
if (!providerTool) throw new Error('Affinity agent tool was not created')
48+
return prepareToolExecution(providerTool, modelArgs, {}, undefined).executionParams
49+
}
50+
51+
const pinnedStatusOption = {
52+
listId: 'l1',
53+
fieldId: 'f1',
54+
optionType: 'status-dropdown',
55+
optionText: 'Won',
56+
optionColor: 'green',
57+
optionStatusCategory: 'won',
58+
}
59+
60+
it('fails the call instead of sending the model fields over the pinned option', async () => {
61+
await expect(
62+
prepare(pinnedStatusOption, { rank: 2, winRate: 150, type: 'ranked-dropdown', text: 'X' })
63+
).rejects.toThrow(ToolCallParamsError)
64+
})
65+
66+
it.each([
67+
['Option Rank', { optionRank: ' ' }, { rank: 2.5 }],
68+
['Win Rate', { optionWinRate: ' ' }, { rank: 1, winRate: 250 }],
69+
])('validates the model value behind a blank %s', async (_label, stored, modelArgs) => {
70+
await expect(prepare({ ...pinnedStatusOption, ...stored }, modelArgs)).rejects.toThrow(
71+
ToolCallParamsError
72+
)
73+
})
74+
75+
it('sends a valid model rank behind a blank Option Rank', async () => {
76+
const params = await prepare({ ...pinnedStatusOption, optionRank: ' ' }, { rank: 3 })
77+
expect(params).toMatchObject({ type: 'status-dropdown', text: 'Won', rank: 3 })
78+
})
79+
})

‎apps/sim/blocks/blocks/affinity.ts‎

Lines changed: 171 additions & 172 deletions
Large diffs are not rendered by default.

‎apps/sim/blocks/blocks/mailgun.test.ts‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
*/
77
import { describe, expect, it } from 'vitest'
88
import { MailgunV2Block } from '@/blocks/blocks/mailgun'
9+
import type { BlockToolParamsContext } from '@/blocks/types'
910
import { mailgunAddListMemberTool } from '@/tools/mailgun/add_list_member'
1011
import { mailgunGetMailingListTool } from '@/tools/mailgun/get_mailing_list'
1112
import type { ToolConfig } from '@/tools/types'
13+
import { validateRequiredParametersAfterMerge } from '@/tools/utils'
1214

1315
function mapParams(
1416
inputs: Record<string, unknown>,
15-
context?: { operation: string }
17+
context?: BlockToolParamsContext
1618
): Record<string, unknown> {
1719
const mapped = MailgunV2Block.tools.config?.params?.(inputs, context) ?? {}
1820
return { ...inputs, ...mapped }
@@ -59,6 +61,31 @@ describe('Mailgun block add_list_member mapping', () => {
5961
expect(formFields(params)).toMatchObject({ address: 'bob@example.com', name: 'Bob' })
6062
})
6163

64+
it('adds the member even when the model names the list address as the member', () => {
65+
const params = mapParams(
66+
{ apiKey: 'key', listAddress: 'news@mg.example.com', address: 'news@mg.example.com' },
67+
{ operation: 'add_list_member', pinnedParams: new Set(['apiKey']) }
68+
)
69+
expect(formFields(params).address).toBe('news@mg.example.com')
70+
})
71+
72+
it('never adds the row-saved List Address to its own list as a member', () => {
73+
const params = mapParams(
74+
{ apiKey: 'key', address: 'news@mg.example.com' },
75+
{ operation: 'add_list_member', pinnedParams: new Set(['apiKey', 'address']) }
76+
)
77+
expect(requestUrl(mailgunAddListMemberTool, params)).toBe(
78+
'https://api.mailgun.net/v3/lists/news@mg.example.com/members'
79+
)
80+
expect(() =>
81+
validateRequiredParametersAfterMerge(
82+
'mailgun_add_list_member',
83+
mailgunAddListMemberTool,
84+
params
85+
)
86+
).toThrow('Address is required')
87+
})
88+
6289
it.each([
6390
['a stored string', 'false', 'no'],
6491
['a model boolean', false, 'no'],

‎apps/sim/blocks/blocks/mailgun.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -405,12 +405,17 @@ Return ONLY the JSON object - no explanations or markdown.`,
405405
const { memberAddress, memberName, ...rest } = params
406406

407407
if (mapperOperation(params, context) === 'add_list_member') {
408-
const modelMemberAddress =
409-
params.address !== params.listAddress ? params.address : undefined
408+
/**
409+
* The block's List Address field is stored under `address`, the tool's member param.
410+
* On the canvas, and on a tool call whose row saved that field, `address` is the list;
411+
* otherwise it is the member the model named.
412+
*/
413+
const addressIsList =
414+
!isToolCall(context) || Boolean(context?.pinnedParams?.has('address'))
410415
return {
411416
...rest,
412-
listAddress: toolCallArg(context, params.listAddress) || params.address,
413-
address: memberAddress || toolCallArg(context, modelMemberAddress),
417+
listAddress: addressIsList ? params.address : params.listAddress,
418+
address: memberAddress || (addressIsList ? undefined : params.address),
414419
name: memberName || toolCallArg(context, params.name),
415420
subscribed: isToolCall(context)
416421
? parseOptionalBooleanInput(params.subscribed)

‎apps/sim/blocks/blocks/perplexity.test.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,15 @@ describe('Perplexity tool calls', () => {
2525
expect(result.search_domain_filter).toEqual(['nature.com', 'science.org'])
2626
})
2727
})
28+
29+
describe('Perplexity canvas', () => {
30+
it('sends a Temperature of 0 on Chat', () => {
31+
const result = mapParams({
32+
operation: 'perplexity_chat',
33+
apiKey: 'k',
34+
content: 'q',
35+
temperature: 0,
36+
})
37+
expect(result.temperature).toBe(0)
38+
})
39+
})

‎apps/sim/blocks/blocks/perplexity.ts‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { PerplexityIcon } from '@/components/icons'
22
import { AuthMode, type BlockConfig, type BlockMeta, IntegrationType } from '@/blocks/types'
3-
import { mapperOperation, toolCallArg } from '@/blocks/utils'
3+
import { mapperOperation } from '@/blocks/utils'
44

55
export const PerplexityBlock: BlockConfig = {
66
type: 'perplexity',
@@ -238,11 +238,12 @@ Return ONLY the date string in MM/DD/YYYY format - no explanations, no quotes, n
238238
content: params.content,
239239
systemPrompt: params.systemPrompt,
240240
max_tokens: params.max_tokens ? Number.parseInt(params.max_tokens) : undefined,
241-
temperature: params.temperature
242-
? Number.parseFloat(params.temperature)
243-
: params.temperature === 0
244-
? toolCallArg(context, 0)
245-
: undefined,
241+
temperature:
242+
params.temperature === 0
243+
? 0
244+
: params.temperature
245+
? Number.parseFloat(params.temperature)
246+
: undefined,
246247
}
247248

248249
return chatParams

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

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
import { describe, expect, it } from 'vitest'
2-
import { ResendV2Block } from '@/blocks/blocks/resend'
3-
import type { BlockToolParamsContext } from '@/blocks/types'
1+
import { describe, expect, it, vi } from 'vitest'
2+
import { ResendBlock, ResendV2Block } from '@/blocks/blocks/resend'
3+
import type { BlockConfig, BlockToolParamsContext } from '@/blocks/types'
4+
import { collectBlockFieldIssues } from '@/serializer/index'
5+
6+
/** Lint checks fields against the real tool params, which vitest.setup.ts mocks empty. */
7+
vi.unmock('@/tools/metadata')
48

59
function mapParams(params: Record<string, unknown>, context?: BlockToolParamsContext) {
610
const mapper = ResendV2Block.tools.config?.params
@@ -40,3 +44,54 @@ describe('Resend list pagination limit', () => {
4044
expect(mapParams({ operation: 'list_domains', limit: '' }).limit).toBeUndefined()
4145
})
4246
})
47+
48+
describe('Resend Create Broadcast recipient', () => {
49+
function missingFields(config: BlockConfig, values: Record<string, string>) {
50+
const params = {
51+
operation: 'create_broadcast',
52+
broadcastFrom: 'news@example.com',
53+
broadcastSubject: 'Hi',
54+
...values,
55+
}
56+
const subBlocks = Object.fromEntries(
57+
Object.entries(params).map(([id, value]) => [id, { id, type: 'short-input' as const, value }])
58+
)
59+
const block = {
60+
id: 'b1',
61+
type: config.type,
62+
name: 'Resend',
63+
enabled: true,
64+
position: { x: 0, y: 0 },
65+
subBlocks,
66+
outputs: {},
67+
data: {},
68+
}
69+
return collectBlockFieldIssues(block, config, params, { mode: 'lint' }).missingRequiredFields
70+
}
71+
72+
it.each([ResendBlock, ResendV2Block])(
73+
'flags Audience ID only when no segment is given',
74+
(config) => {
75+
expect(missingFields(config, { segmentId: '', audienceId: '' })).toContain('Audience ID')
76+
expect(missingFields(config, { segmentId: 'seg_1', audienceId: '' })).not.toContain(
77+
'Audience ID'
78+
)
79+
expect(missingFields(config, { segmentId: '', audienceId: 'aud_1' })).not.toContain(
80+
'Audience ID'
81+
)
82+
}
83+
)
84+
85+
it.each([ResendBlock, ResendV2Block])(
86+
'publishes Audience ID as required only for the audience operations when no values are known',
87+
(config) => {
88+
const audienceId = config.subBlocks.find((subBlock) => subBlock.id === 'audienceId')
89+
const required = audienceId?.required
90+
if (typeof required !== 'function') throw new Error('Audience ID requirement is not dynamic')
91+
expect(required()).toEqual({
92+
field: 'operation',
93+
value: ['get_audience', 'delete_audience'],
94+
})
95+
}
96+
)
97+
})

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,18 @@ Return ONLY the email body - no explanations, no extra text.`,
317317
field: 'operation',
318318
value: ['get_audience', 'delete_audience', 'create_broadcast'],
319319
},
320-
required: {
320+
/**
321+
* Create Broadcast needs an audience only when no segment is set. Without block values (the
322+
* public catalog, Copilot validation) a segment may still be given, so only the audience
323+
* operations require it.
324+
*/
325+
required: (values) => ({
321326
field: 'operation',
322-
value: ['get_audience', 'delete_audience'],
323-
},
327+
value:
328+
values && !String(values.segmentId ?? '').trim()
329+
? ['get_audience', 'delete_audience', 'create_broadcast']
330+
: ['get_audience', 'delete_audience'],
331+
}),
324332
},
325333

326334
{

‎apps/sim/blocks/blocks/sailpoint.test.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { describe, expect, it } from 'vitest'
22
import { SailPointV2Block } from '@/blocks/blocks/sailpoint'
33
import type { BlockToolParamsContext } from '@/blocks/types'
4+
import { sailpointSearchTool } from '@/tools/sailpoint/definitions'
45

56
function mapParams(params: Record<string, unknown>, context?: BlockToolParamsContext) {
67
const mapper = SailPointV2Block.tools.config?.params
@@ -63,6 +64,24 @@ describe('SailPoint search list fields', () => {
6364
'displayName,-id'
6465
)
6566
})
67+
68+
it.each([
69+
[
70+
'a canvas JSON number',
71+
canvasToolInput({ operation: 'sailpoint_search', searchAfter: '12345' }),
72+
],
73+
['a model number', toolCallInput({ searchAfter: 12345 }, 'sailpoint_search')],
74+
])('sends a lone searchAfter given as %s as a one-entry string list', (_label, input) => {
75+
const operationInput = sailpointSearchTool.operation?.input
76+
if (!operationInput) throw new Error('SailPoint search has no operation input')
77+
const request = operationInput({
78+
...input,
79+
tenant: 't',
80+
accessToken: 'token',
81+
query: { query: '*' },
82+
})
83+
expect(request).toMatchObject({ searchAfter: ['12345'] })
84+
})
6685
})
6786

6887
describe('SailPoint canvas selector gates', () => {

‎apps/sim/lib/workflows/search-replace/indexer.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ const DISPLAY_ONLY_SUBBLOCK_TYPES = new Set<SubBlockType>([
137137
'webhook-config',
138138
])
139139

140-
const TEXT_VALUE_ONLY_SUBBLOCK_TYPES = new Set<SubBlockType>(['filter-builder', 'variables-input'])
141140
const DISPLAY_LABEL_READONLY_REASON = 'Display labels cannot be replaced'
142141

143142
const TOOL_INPUT_TEXT_EXCLUDED_LEAF_KEYS = new Set([
@@ -227,9 +226,6 @@ function isSearchableLeafPath(
227226
return false
228227
}
229228
}
230-
if (mode === 'text' && subBlockType && TEXT_VALUE_ONLY_SUBBLOCK_TYPES.has(subBlockType)) {
231-
return lastSegment === 'value'
232-
}
233229
if (
234230
mode === 'text' &&
235231
(subBlockType === 'input-format' ||

0 commit comments

Comments
 (0)