Skip to content

Commit 0ecf635

Browse files
committed
fix(blocks): restore field renames to tool() for serialization-time validation
Field renames (e.g. personalApiKey→apiKey) must be in tool() because validateRequiredFieldsBeforeExecution calls selectToolId()→tool() then checks renamed field names on params. Only type coercions (Number(), boolean) stay in params() to avoid destroying dynamic variable references.
1 parent 4d7885a commit 0ecf635

File tree

5 files changed

+36
-37
lines changed

5 files changed

+36
-37
lines changed

apps/sim/blocks/blocks/grafana.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,11 @@ Return ONLY the folder title - no explanations, no quotes, no extra text.`,
606606
],
607607
config: {
608608
tool: (params) => {
609+
if (params.alertTitle) params.title = params.alertTitle
610+
if (params.folderTitle) params.title = params.folderTitle
611+
if (params.folderUidNew) params.uid = params.folderUidNew
612+
if (params.annotationTags) params.tags = params.annotationTags
613+
if (params.annotationDashboardUid) params.dashboardUid = params.annotationDashboardUid
609614
return params.operation
610615
},
611616
params: (params) => {
@@ -616,11 +621,6 @@ Return ONLY the folder title - no explanations, no quotes, no extra text.`,
616621
if (params.timeEnd) result.timeEnd = Number(params.timeEnd)
617622
if (params.from) result.from = Number(params.from)
618623
if (params.to) result.to = Number(params.to)
619-
if (params.alertTitle) result.title = params.alertTitle
620-
if (params.folderTitle) result.title = params.folderTitle
621-
if (params.folderUidNew) result.uid = params.folderUidNew
622-
if (params.annotationTags) result.tags = params.annotationTags
623-
if (params.annotationDashboardUid) result.dashboardUid = params.annotationDashboardUid
624624
return result
625625
},
626626
},

apps/sim/blocks/blocks/lemlist.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ export const LemlistBlock: BlockConfig<LemlistResponse> = {
169169
access: ['lemlist_get_activities', 'lemlist_get_lead', 'lemlist_send_email'],
170170
config: {
171171
tool: (params) => {
172+
if (params.filterLeadId) params.leadId = params.filterLeadId
172173
switch (params.operation) {
173174
case 'get_activities':
174175
return 'lemlist_get_activities'
@@ -184,7 +185,6 @@ export const LemlistBlock: BlockConfig<LemlistResponse> = {
184185
const result: Record<string, unknown> = {}
185186
if (params.limit) result.limit = Number(params.limit)
186187
if (params.offset) result.offset = Number(params.offset)
187-
if (params.filterLeadId) result.leadId = params.filterLeadId
188188
return result
189189
},
190190
},

apps/sim/blocks/blocks/parallel.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ export const ParallelBlock: BlockConfig<ToolResponse> = {
149149
access: ['parallel_search', 'parallel_extract', 'parallel_deep_research'],
150150
config: {
151151
tool: (params) => {
152+
if (params.extract_objective) params.objective = params.extract_objective
153+
if (params.research_input) params.input = params.research_input
152154
switch (params.operation) {
153155
case 'search':
154156
return 'parallel_search'
@@ -183,15 +185,10 @@ export const ParallelBlock: BlockConfig<ToolResponse> = {
183185
}
184186

185187
if (operation === 'extract') {
186-
result.objective = params.extract_objective
187188
result.excerpts = !(params.excerpts === 'false' || params.excerpts === false)
188189
result.full_content = params.full_content === 'true' || params.full_content === true
189190
}
190191

191-
if (operation === 'deep_research') {
192-
result.input = params.research_input
193-
}
194-
195192
return result
196193
},
197194
},

apps/sim/blocks/blocks/posthog.ts

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,20 +1185,13 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
11851185
],
11861186
config: {
11871187
tool: (params) => {
1188-
return params.operation as string
1189-
},
1190-
params: (params) => {
1191-
const result: Record<string, unknown> = {}
1192-
if (params.limit) result.limit = Number(params.limit)
1193-
if (params.offset) result.offset = Number(params.offset)
1194-
if (params.rolloutPercentage) result.rolloutPercentage = Number(params.rolloutPercentage)
1195-
if (params.responsesLimit) result.responsesLimit = Number(params.responsesLimit)
1196-
1188+
// Field renames in tool() are safe (they copy values, not coerce types)
1189+
// and are needed for serialization-time validation of required fields
11971190
if (params.operation === 'posthog_get_project' && params.projectIdParam) {
1198-
result.projectId = params.projectIdParam
1191+
params.projectId = params.projectIdParam
11991192
}
12001193
if (params.personalApiKey) {
1201-
result.apiKey = params.personalApiKey
1194+
params.apiKey = params.personalApiKey
12021195
}
12031196

12041197
const flagOps = [
@@ -1207,47 +1200,47 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
12071200
'posthog_delete_feature_flag',
12081201
]
12091202
if (flagOps.includes(params.operation as string) && params.featureFlagId) {
1210-
result.flagId = params.featureFlagId
1203+
params.flagId = params.featureFlagId
12111204
}
12121205

12131206
if (
12141207
(params.operation === 'posthog_create_survey' ||
12151208
params.operation === 'posthog_update_survey') &&
12161209
params.surveyType
12171210
) {
1218-
result.type = params.surveyType
1211+
params.type = params.surveyType
12191212
}
12201213

12211214
if (params.operation === 'posthog_create_cohort' && params.isStatic !== undefined) {
1222-
result.is_static = params.isStatic
1215+
params.is_static = params.isStatic
12231216
}
12241217

12251218
if (params.operation === 'posthog_create_annotation' && params.dateMarker) {
1226-
result.date_marker = params.dateMarker
1219+
params.date_marker = params.dateMarker
12271220
}
12281221

12291222
if (params.operation === 'posthog_update_property_definition' && params.propertyType) {
1230-
result.property_type = params.propertyType
1223+
params.property_type = params.propertyType
12311224
}
12321225

12331226
if (params.operation === 'posthog_create_insight' && params.insightQuery) {
1234-
result.query = params.insightQuery
1227+
params.query = params.insightQuery
12351228
}
12361229

12371230
if (params.operation === 'posthog_create_insight' && params.insightTags) {
1238-
result.tags = params.insightTags
1231+
params.tags = params.insightTags
12391232
}
12401233

12411234
if (params.operation === 'posthog_list_persons' && params.distinctIdFilter) {
1242-
result.distinctId = params.distinctIdFilter
1235+
params.distinctId = params.distinctIdFilter
12431236
}
12441237

12451238
if (params.operation === 'posthog_create_experiment') {
12461239
if (params.experimentStartDate) {
1247-
result.startDate = params.experimentStartDate
1240+
params.startDate = params.experimentStartDate
12481241
}
12491242
if (params.experimentEndDate) {
1250-
result.endDate = params.experimentEndDate
1243+
params.endDate = params.experimentEndDate
12511244
}
12521245
}
12531246

@@ -1256,13 +1249,22 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
12561249
params.operation === 'posthog_update_survey'
12571250
) {
12581251
if (params.surveyStartDate) {
1259-
result.startDate = params.surveyStartDate
1252+
params.startDate = params.surveyStartDate
12601253
}
12611254
if (params.surveyEndDate) {
1262-
result.endDate = params.surveyEndDate
1255+
params.endDate = params.surveyEndDate
12631256
}
12641257
}
12651258

1259+
return params.operation as string
1260+
},
1261+
params: (params) => {
1262+
const result: Record<string, unknown> = {}
1263+
if (params.limit) result.limit = Number(params.limit)
1264+
if (params.offset) result.offset = Number(params.offset)
1265+
if (params.rolloutPercentage) result.rolloutPercentage = Number(params.rolloutPercentage)
1266+
if (params.responsesLimit) result.responsesLimit = Number(params.responsesLimit)
1267+
12661268
return result
12671269
},
12681270
},

apps/sim/blocks/blocks/spotify.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,9 @@ export const SpotifyBlock: BlockConfig<ToolResponse> = {
755755
],
756756
config: {
757757
tool: (params) => {
758+
if (params.followType) params.type = params.followType
759+
if (params.newName) params.name = params.newName
760+
if (params.playUris) params.uris = params.playUris
758761
return params.operation || 'spotify_search'
759762
},
760763
params: (params) => {
@@ -765,9 +768,6 @@ export const SpotifyBlock: BlockConfig<ToolResponse> = {
765768
if (params.insert_before) result.insert_before = Number(params.insert_before)
766769
if (params.range_length) result.range_length = Number(params.range_length)
767770
if (params.position_ms) result.position_ms = Number(params.position_ms)
768-
if (params.followType) result.type = params.followType
769-
if (params.newName) result.name = params.newName
770-
if (params.playUris) result.uris = params.playUris
771771
if (params.coverImage !== undefined) {
772772
result.coverImage = normalizeFileInput(params.coverImage, { single: true })
773773
}

0 commit comments

Comments
 (0)