Skip to content

Commit 4d3663e

Browse files
committed
fix(sendgrid): dedupe active coercion between block and tool
Per Cursor Bugbot: the block's pre-coercion only recognized the dropdown string 'true' or boolean true as active, so a dynamic reference producing numeric 1 or string '1' fell through to 0 and silently created an inactive template version. Exported the tool's toActiveFlag and reused it in the block instead of duplicating the inactive-value logic, so both layers can no longer drift out of sync.
1 parent 79d3b94 commit 4d3663e

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

apps/sim/blocks/blocks/sendgrid.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { SendgridIcon } from '@/components/icons'
22
import type { BlockConfig, BlockMeta } from '@/blocks/types'
33
import { AuthMode, IntegrationType } from '@/blocks/types'
44
import { normalizeFileInput } from '@/blocks/utils'
5+
import { toActiveFlag } from '@/tools/sendgrid/create_template_version'
56
import type { SendMailResult } from '@/tools/sendgrid/types'
67

78
export const SendGridBlock: BlockConfig<SendMailResult> = {
@@ -623,7 +624,7 @@ Return ONLY the HTML content.`,
623624
...(operation === 'list_templates' &&
624625
templatePageToken && { pageToken: templatePageToken }),
625626
...(normalizedAttachments && { attachments: normalizedAttachments }),
626-
...(active !== undefined && { active: active === 'true' || active === true ? 1 : 0 }),
627+
...(active !== undefined && { active: toActiveFlag(active) }),
627628
}
628629
},
629630
},

apps/sim/tools/sendgrid/create_template_version.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import type { ToolConfig } from '@/tools/types'
77

88
const INACTIVE_VALUES: unknown[] = [false, 'false', 0, '0']
99

10-
function toActiveFlag(active: CreateTemplateVersionParams['active']): 0 | 1 {
10+
/** Coerces any dynamic-reference form of SendGrid's active flag (boolean, string, or
11+
* number) to the 0/1 integer the API requires. Shared with the block's own
12+
* pre-coercion in blocks/blocks/sendgrid.ts so both layers stay in sync. */
13+
export function toActiveFlag(active: unknown): 0 | 1 {
1114
if (active === undefined) return 1
1215
return INACTIVE_VALUES.includes(active) ? 0 : 1
1316
}

0 commit comments

Comments
 (0)