Skip to content

Commit e5cd4f8

Browse files
committed
fix(dub): require a link selector for bulk update links
Bulk Update Links could run with only Update Data and no Link IDs or External IDs, sending Dub a request with no target links and producing a confusing API error. Guard the tool to throw a clear validation error when neither selector is provided, and clarify the block placeholder.
1 parent 86e259d commit e5cd4f8

2 files changed

Lines changed: 22 additions & 5 deletions

File tree

apps/sim/blocks/blocks/dub.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ export const DubBlock: BlockConfig<DubResponse> = {
481481
id: 'bulkUpdateLinkIds',
482482
title: 'Link IDs',
483483
type: 'short-input',
484-
placeholder: 'Comma-separated link IDs (max 100)',
484+
placeholder: 'Comma-separated link IDs (required unless External IDs is set)',
485485
condition: { field: 'operation', value: 'bulk_update_links' },
486486
},
487487
{

apps/sim/tools/dub/bulk_update_links.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,28 @@ export const bulkUpdateLinksTool: ToolConfig<DubBulkUpdateLinksParams, DubBulkUp
4747
}),
4848
body: (params) => {
4949
const data = typeof params.data === 'string' ? JSON.parse(params.data) : params.data
50+
const linkIds = params.linkIds
51+
? params.linkIds
52+
.split(',')
53+
.map((id) => id.trim())
54+
.filter(Boolean)
55+
: []
56+
const externalIds = params.externalIds
57+
? params.externalIds
58+
.split(',')
59+
.map((id) => id.trim())
60+
.filter(Boolean)
61+
: []
62+
if (linkIds.length === 0 && externalIds.length === 0) {
63+
throw new Error(
64+
'Bulk Update Links requires at least one Link ID or External ID to select which links to update.'
65+
)
66+
}
5067
const body: Record<string, unknown> = { data: data ?? {} }
51-
if (params.linkIds) {
52-
body.linkIds = params.linkIds.split(',').map((id) => id.trim())
53-
} else if (params.externalIds) {
54-
body.externalIds = params.externalIds.split(',').map((id) => id.trim())
68+
if (linkIds.length > 0) {
69+
body.linkIds = linkIds
70+
} else {
71+
body.externalIds = externalIds
5572
}
5673
return body
5774
},

0 commit comments

Comments
 (0)