Skip to content

Commit 9ccc360

Browse files
committed
fix(blocks): return an empty string from mapperOperation when no operation is set
1 parent 07ea55e commit 9ccc360

3 files changed

Lines changed: 6 additions & 7 deletions

File tree

‎apps/sim/blocks/blocks/monday.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,7 @@ export const MondayBlock: BlockConfig = {
525525
const baseParams: Record<string, unknown> = {
526526
oauthCredential: params.oauthCredential,
527527
}
528-
/** Agent tool calls carry the stored operation only on `context`, not in `params`. */
529-
const rawOperation = mapperOperation(params, context)
530-
const op = typeof rawOperation === 'string' ? rawOperation.trim() : 'list_boards'
528+
const op = mapperOperation(params, context).trim() || 'list_boards'
531529

532530
switch (op) {
533531
case 'list_boards':

‎apps/sim/blocks/blocks/quickbooks.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2526,7 +2526,7 @@ export const QuickBooksBlock: BlockConfig = {
25262526
return operation
25272527
},
25282528
params: (params, context) => {
2529-
const operation = String(mapperOperation(params, context))
2529+
const operation = mapperOperation(params, context)
25302530
const oauthCredentialValue = params.oauthCredential
25312531
/**
25322532
* Resolves a tool param filled by a differently-named subBlock. On an agent tool call

‎apps/sim/blocks/utils.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -952,14 +952,15 @@ export function toolCallArg<T>(
952952
* The operation a block's `tools.config.params` mapper runs for. A tool call passes it only in
953953
* `context`: a stored tool row keeps its operation outside its params, and a tool that declares its
954954
* own `operation` param (Slack `edit_canvas`) gets the model's value there. The canvas passes no
955-
* context, so the block's serialized `operation` input is used.
955+
* context, so the block's serialized `operation` input is used. Returns `''` when neither supplies
956+
* one, so a default needs `||`, not `??`.
956957
*/
957958
export function mapperOperation(
958959
params: { operation?: unknown },
959960
context: BlockToolParamsContext | undefined
960-
): string | undefined {
961+
): string {
961962
if (context?.operation) return context.operation
962-
return typeof params.operation === 'string' ? params.operation : undefined
963+
return typeof params.operation === 'string' ? params.operation : ''
963964
}
964965

965966
/**

0 commit comments

Comments
 (0)