From 05ae4a693af32b0365cddbdfb309bb6bc4d1ee15 Mon Sep 17 00:00:00 2001 From: waleed Date: Thu, 2 Jul 2026 00:06:17 -0700 Subject: [PATCH 01/10] fix(sendgrid): fix active field coercion, add pagination, tighten output typing - Fix active field for create_template_version being sent as the string "true"/"false" instead of the SendGrid-required int 0/1 - Add missing authMode: ApiKey on SendGridBlock - Add pageToken/nextPageToken pagination support to list_templates and list_all_lists (SendGrid page_token cursor, parsed from _metadata.next) - Fix nullable output fields to use ?? null / ?? [] with optional: true across get_contact, search_contacts, remove_contacts_from_list, create_template_version, add_contact, send_mail - Remove dead data.templates fallback in list_templates (API only ever returns result) - Remove unused UpdateContactParams/UpdateListParams/UpdateTemplateParams dead types; make CreateTemplateParams.generation optional to match actual tool behavior --- apps/sim/blocks/blocks/sendgrid.ts | 31 +++++++++++++++- apps/sim/tools/sendgrid/add_contact.ts | 12 ++++-- .../tools/sendgrid/create_template_version.ts | 12 +++--- apps/sim/tools/sendgrid/get_contact.ts | 20 ++++++---- apps/sim/tools/sendgrid/list_all_lists.ts | 31 +++++++++++++++- apps/sim/tools/sendgrid/list_templates.ts | 30 +++++++++++++-- .../sendgrid/remove_contacts_from_list.ts | 4 +- apps/sim/tools/sendgrid/search_contacts.ts | 8 +++- apps/sim/tools/sendgrid/send_mail.ts | 2 +- apps/sim/tools/sendgrid/types.ts | 37 ++++++------------- 10 files changed, 132 insertions(+), 55 deletions(-) diff --git a/apps/sim/blocks/blocks/sendgrid.ts b/apps/sim/blocks/blocks/sendgrid.ts index 9378083564d..7df8eca73bd 100644 --- a/apps/sim/blocks/blocks/sendgrid.ts +++ b/apps/sim/blocks/blocks/sendgrid.ts @@ -1,6 +1,6 @@ import { SendgridIcon } from '@/components/icons' import type { BlockConfig, BlockMeta } from '@/blocks/types' -import { IntegrationType } from '@/blocks/types' +import { AuthMode, IntegrationType } from '@/blocks/types' import { normalizeFileInput } from '@/blocks/utils' import type { SendMailResult } from '@/tools/sendgrid/types' @@ -13,6 +13,7 @@ export const SendGridBlock: BlockConfig = { docsLink: 'https://docs.sim.ai/integrations/sendgrid', category: 'tools', integrationType: IntegrationType.Email, + authMode: AuthMode.ApiKey, bgColor: '#1A82E2', icon: SendgridIcon, @@ -387,6 +388,14 @@ Return ONLY the JSON array.`, condition: { field: 'operation', value: 'list_all_lists' }, mode: 'advanced', }, + { + id: 'listPageToken', + title: 'Page Token', + type: 'short-input', + placeholder: 'Page token from a previous response', + condition: { field: 'operation', value: 'list_all_lists' }, + mode: 'advanced', + }, // Template fields { id: 'templateName', @@ -434,6 +443,14 @@ Return ONLY the JSON array.`, condition: { field: 'operation', value: 'list_templates' }, mode: 'advanced', }, + { + id: 'templatePageToken', + title: 'Page Token', + type: 'short-input', + placeholder: 'Page token from a previous response', + condition: { field: 'operation', value: 'list_templates' }, + mode: 'advanced', + }, { id: 'versionName', title: 'Version Name', @@ -579,7 +596,10 @@ Return ONLY the HTML content.`, templateGenerations, listPageSize, templatePageSize, + listPageToken, + templatePageToken, attachments, + active, ...rest } = params @@ -599,7 +619,10 @@ Return ONLY the HTML content.`, ...(templateGenerations && { generations: templateGenerations }), ...(listPageSize && { pageSize: listPageSize }), ...(templatePageSize && { pageSize: templatePageSize }), + ...(listPageToken && { pageToken: listPageToken }), + ...(templatePageToken && { pageToken: templatePageToken }), ...(normalizedAttachments && { attachments: normalizedAttachments }), + ...(active !== undefined && { active: active === 'true' ? 1 : 0 }), } }, }, @@ -637,12 +660,14 @@ Return ONLY the HTML content.`, listName: { type: 'string', description: 'List name' }, listId: { type: 'string', description: 'List ID' }, listPageSize: { type: 'number', description: 'Page size for listing lists' }, + listPageToken: { type: 'string', description: 'Page token for listing lists' }, // Template inputs templateName: { type: 'string', description: 'Template name' }, templateId: { type: 'string', description: 'Template ID' }, generation: { type: 'string', description: 'Template generation' }, templateGenerations: { type: 'string', description: 'Filter templates by generation' }, templatePageSize: { type: 'number', description: 'Page size for listing templates' }, + templatePageToken: { type: 'string', description: 'Page token for listing templates' }, versionName: { type: 'string', description: 'Template version name' }, templateSubject: { type: 'string', description: 'Template subject' }, htmlContent: { type: 'string', description: 'HTML content' }, @@ -677,6 +702,10 @@ Return ONLY the HTML content.`, templates: { type: 'json', description: 'Array of templates' }, generation: { type: 'string', description: 'Template generation' }, versions: { type: 'json', description: 'Array of template versions' }, + nextPageToken: { + type: 'string', + description: 'Token for the next page of results (list_all_lists, list_templates)', + }, // Template version outputs templateId: { type: 'string', description: 'Template ID' }, active: { type: 'boolean', description: 'Whether template version is active' }, diff --git a/apps/sim/tools/sendgrid/add_contact.ts b/apps/sim/tools/sendgrid/add_contact.ts index 5c483e9737b..7c273f401eb 100644 --- a/apps/sim/tools/sendgrid/add_contact.ts +++ b/apps/sim/tools/sendgrid/add_contact.ts @@ -99,7 +99,7 @@ export const sendGridAddContactTool: ToolConfig return { success: true, output: { - jobId: data.job_id, + jobId: data.job_id ?? null, email: params?.email || '', firstName: params?.firstName, lastName: params?.lastName, @@ -110,10 +110,14 @@ export const sendGridAddContactTool: ToolConfig }, outputs: { - jobId: { type: 'string', description: 'Job ID for tracking the async contact creation' }, + jobId: { + type: 'string', + description: 'Job ID for tracking the async contact creation', + optional: true, + }, email: { type: 'string', description: 'Contact email address' }, - firstName: { type: 'string', description: 'Contact first name' }, - lastName: { type: 'string', description: 'Contact last name' }, + firstName: { type: 'string', description: 'Contact first name', optional: true }, + lastName: { type: 'string', description: 'Contact last name', optional: true }, message: { type: 'string', description: 'Status message' }, }, } diff --git a/apps/sim/tools/sendgrid/create_template_version.ts b/apps/sim/tools/sendgrid/create_template_version.ts index e41f43bb584..7d9e5e07aa1 100644 --- a/apps/sim/tools/sendgrid/create_template_version.ts +++ b/apps/sim/tools/sendgrid/create_template_version.ts @@ -101,9 +101,9 @@ export const sendGridCreateTemplateVersionTool: ToolConfig< name: data.name, subject: data.subject, active: data.active === 1, - htmlContent: data.html_content, - plainContent: data.plain_content, - updatedAt: data.updated_at, + htmlContent: data.html_content ?? null, + plainContent: data.plain_content ?? null, + updatedAt: data.updated_at ?? null, }, } }, @@ -114,8 +114,8 @@ export const sendGridCreateTemplateVersionTool: ToolConfig< name: { type: 'string', description: 'Version name' }, subject: { type: 'string', description: 'Email subject' }, active: { type: 'boolean', description: 'Whether this version is active' }, - htmlContent: { type: 'string', description: 'HTML content' }, - plainContent: { type: 'string', description: 'Plain text content' }, - updatedAt: { type: 'string', description: 'Last update timestamp' }, + htmlContent: { type: 'string', description: 'HTML content', optional: true }, + plainContent: { type: 'string', description: 'Plain text content', optional: true }, + updatedAt: { type: 'string', description: 'Last update timestamp', optional: true }, }, } diff --git a/apps/sim/tools/sendgrid/get_contact.ts b/apps/sim/tools/sendgrid/get_contact.ts index f2870d854ff..549d96df0c2 100644 --- a/apps/sim/tools/sendgrid/get_contact.ts +++ b/apps/sim/tools/sendgrid/get_contact.ts @@ -47,8 +47,8 @@ export const sendGridGetContactTool: ToolConfig lastName: data.last_name, createdAt: data.created_at, updatedAt: data.updated_at, - listIds: data.list_ids, - customFields: data.custom_fields, + listIds: data.list_ids ?? [], + customFields: data.custom_fields ?? null, }, } }, @@ -56,11 +56,15 @@ export const sendGridGetContactTool: ToolConfig outputs: { id: { type: 'string', description: 'Contact ID' }, email: { type: 'string', description: 'Contact email address' }, - firstName: { type: 'string', description: 'Contact first name' }, - lastName: { type: 'string', description: 'Contact last name' }, - createdAt: { type: 'string', description: 'Creation timestamp' }, - updatedAt: { type: 'string', description: 'Last update timestamp' }, - listIds: { type: 'json', description: 'Array of list IDs the contact belongs to' }, - customFields: { type: 'json', description: 'Custom field values' }, + firstName: { type: 'string', description: 'Contact first name', optional: true }, + lastName: { type: 'string', description: 'Contact last name', optional: true }, + createdAt: { type: 'string', description: 'Creation timestamp', optional: true }, + updatedAt: { type: 'string', description: 'Last update timestamp', optional: true }, + listIds: { + type: 'json', + description: 'Array of list IDs the contact belongs to', + optional: true, + }, + customFields: { type: 'json', description: 'Custom field values', optional: true }, }, } diff --git a/apps/sim/tools/sendgrid/list_all_lists.ts b/apps/sim/tools/sendgrid/list_all_lists.ts index 76adb3d1002..17861dae3ea 100644 --- a/apps/sim/tools/sendgrid/list_all_lists.ts +++ b/apps/sim/tools/sendgrid/list_all_lists.ts @@ -18,7 +18,13 @@ export const sendGridListAllListsTool: ToolConfig = outputs: { success: { type: 'boolean', description: 'Whether the email was sent successfully' }, - messageId: { type: 'string', description: 'SendGrid message ID' }, + messageId: { type: 'string', description: 'SendGrid message ID', optional: true }, to: { type: 'string', description: 'Recipient email address' }, subject: { type: 'string', description: 'Email subject' }, }, diff --git a/apps/sim/tools/sendgrid/types.ts b/apps/sim/tools/sendgrid/types.ts index 03eb10bfccb..b4f02ce3a46 100644 --- a/apps/sim/tools/sendgrid/types.ts +++ b/apps/sim/tools/sendgrid/types.ts @@ -127,15 +127,6 @@ export interface AddContactParams extends SendGridBaseParams { listIds?: string // Comma-separated list IDs } -interface UpdateContactParams extends SendGridBaseParams { - contactId?: string - email: string - firstName?: string - lastName?: string - customFields?: string // JSON string - listIds?: string // Comma-separated list IDs -} - export interface SearchContactsParams extends SendGridBaseParams { query: string } @@ -151,14 +142,14 @@ export interface DeleteContactParams extends SendGridBaseParams { export interface ContactResult extends ToolResponse { output: { id?: string - jobId?: string + jobId?: string | null email: string firstName?: string lastName?: string createdAt?: string updatedAt?: string listIds?: string[] - customFields?: Record + customFields?: Record | null message?: string } } @@ -166,7 +157,7 @@ export interface ContactResult extends ToolResponse { export interface ContactsResult extends ToolResponse { output: { contacts: SendGridContact[] - contactCount?: number + contactCount: number | null } } @@ -179,17 +170,13 @@ export interface GetListParams extends SendGridBaseParams { listId: string } -interface UpdateListParams extends SendGridBaseParams { - listId: string - name: string -} - export interface DeleteListParams extends SendGridBaseParams { listId: string } export interface ListAllListsParams extends SendGridBaseParams { pageSize?: number + pageToken?: string } export interface AddContactsToListParams extends SendGridBaseParams { @@ -213,24 +200,20 @@ export interface ListResult extends ToolResponse { export interface ListsResult extends ToolResponse { output: { lists: SendGridList[] + nextPageToken: string | null } } // Template types export interface CreateTemplateParams extends SendGridBaseParams { name: string - generation: 'legacy' | 'dynamic' + generation?: 'legacy' | 'dynamic' } export interface GetTemplateParams extends SendGridBaseParams { templateId: string } -interface UpdateTemplateParams extends SendGridBaseParams { - templateId: string - name: string -} - export interface DeleteTemplateParams extends SendGridBaseParams { templateId: string } @@ -238,6 +221,7 @@ export interface DeleteTemplateParams extends SendGridBaseParams { export interface ListTemplatesParams extends SendGridBaseParams { generations?: string // 'legacy' or 'dynamic' or both pageSize?: number + pageToken?: string } export interface CreateTemplateVersionParams extends SendGridBaseParams { @@ -262,6 +246,7 @@ export interface TemplateResult extends ToolResponse { export interface TemplatesResult extends ToolResponse { output: { templates: SendGridTemplate[] + nextPageToken: string | null } } @@ -272,8 +257,8 @@ export interface TemplateVersionResult extends ToolResponse { name: string subject: string active: boolean - htmlContent?: string - plainContent?: string - updatedAt?: string + htmlContent: string | null + plainContent: string | null + updatedAt: string | null } } From e3dbb4892686f3f1756547c1abb8a07e8995409a Mon Sep 17 00:00:00 2001 From: waleed Date: Thu, 2 Jul 2026 00:10:29 -0700 Subject: [PATCH 02/10] fix(sendgrid): address Cursor Bugbot findings on pagination and active coercion - Gate listPageToken/templatePageToken remap on operation so a stale token from the other list operation can't override the intended one - Fix active coercion to also treat a real boolean true (from a dynamic reference) as active, not just the dropdown string 'true' --- apps/sim/blocks/blocks/sendgrid.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/sim/blocks/blocks/sendgrid.ts b/apps/sim/blocks/blocks/sendgrid.ts index 7df8eca73bd..fe34410efe3 100644 --- a/apps/sim/blocks/blocks/sendgrid.ts +++ b/apps/sim/blocks/blocks/sendgrid.ts @@ -619,10 +619,11 @@ Return ONLY the HTML content.`, ...(templateGenerations && { generations: templateGenerations }), ...(listPageSize && { pageSize: listPageSize }), ...(templatePageSize && { pageSize: templatePageSize }), - ...(listPageToken && { pageToken: listPageToken }), - ...(templatePageToken && { pageToken: templatePageToken }), + ...(operation === 'list_all_lists' && listPageToken && { pageToken: listPageToken }), + ...(operation === 'list_templates' && + templatePageToken && { pageToken: templatePageToken }), ...(normalizedAttachments && { attachments: normalizedAttachments }), - ...(active !== undefined && { active: active === 'true' ? 1 : 0 }), + ...(active !== undefined && { active: active === 'true' || active === true ? 1 : 0 }), } }, }, From 355222244722498b72436323eeca02282ffa80d4 Mon Sep 17 00:00:00 2001 From: waleed Date: Thu, 2 Jul 2026 00:30:20 -0700 Subject: [PATCH 03/10] fix(sendgrid): coerce active to int at the tool layer too Per Greptile: the block-level active coercion only covered the UI path. A direct sendgrid_create_template_version tool invocation with a boolean active would still send a raw boolean to SendGrid. Coerce to 0/1 in the tool's own request body so both paths are correct. --- apps/sim/tools/sendgrid/create_template_version.ts | 2 +- apps/sim/tools/sendgrid/types.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/sim/tools/sendgrid/create_template_version.ts b/apps/sim/tools/sendgrid/create_template_version.ts index 7d9e5e07aa1..308a87bdfec 100644 --- a/apps/sim/tools/sendgrid/create_template_version.ts +++ b/apps/sim/tools/sendgrid/create_template_version.ts @@ -70,7 +70,7 @@ export const sendGridCreateTemplateVersionTool: ToolConfig< const body: SendGridTemplateVersionRequest = { name: params.name, subject: params.subject, - active: params.active !== undefined ? params.active : 1, + active: params.active !== undefined ? (params.active ? 1 : 0) : 1, } if (params.htmlContent) { diff --git a/apps/sim/tools/sendgrid/types.ts b/apps/sim/tools/sendgrid/types.ts index b4f02ce3a46..60e906b7418 100644 --- a/apps/sim/tools/sendgrid/types.ts +++ b/apps/sim/tools/sendgrid/types.ts @@ -82,7 +82,7 @@ export interface SendGridContactRequest { export interface SendGridTemplateVersionRequest { name: string subject: string - active: number | boolean + active: number html_content?: string plain_content?: string } From f802b6f552b60e1e6b3a727653791c6462f6039f Mon Sep 17 00:00:00 2001 From: waleed Date: Thu, 2 Jul 2026 00:32:28 -0700 Subject: [PATCH 04/10] fix(sendgrid): always send page_size on list_templates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SendGrid's GET /v3/templates requires page_size on every request (no server-side default) — omitting it errors. Default to 20 to match our own documented default when the caller doesn't set one. --- apps/sim/tools/sendgrid/list_templates.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/sim/tools/sendgrid/list_templates.ts b/apps/sim/tools/sendgrid/list_templates.ts index 202b1a94aeb..e2559ab7b0d 100644 --- a/apps/sim/tools/sendgrid/list_templates.ts +++ b/apps/sim/tools/sendgrid/list_templates.ts @@ -40,9 +40,7 @@ export const sendGridListTemplatesTool: ToolConfig Date: Thu, 2 Jul 2026 00:37:14 -0700 Subject: [PATCH 05/10] fix(sendgrid): explicit false/'false' check for active flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per Cursor Bugbot: params.active ? 1 : 0 treated any truthy string (including "false") as active. Extracted a toActiveFlag helper that only treats real false or the string 'false' as inactive, everything else (including unset) defaults to active — matches the tool's documented default. --- apps/sim/tools/sendgrid/create_template_version.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/sim/tools/sendgrid/create_template_version.ts b/apps/sim/tools/sendgrid/create_template_version.ts index 308a87bdfec..18412196c5c 100644 --- a/apps/sim/tools/sendgrid/create_template_version.ts +++ b/apps/sim/tools/sendgrid/create_template_version.ts @@ -5,6 +5,11 @@ import type { } from '@/tools/sendgrid/types' import type { ToolConfig } from '@/tools/types' +function toActiveFlag(active: CreateTemplateVersionParams['active']): 0 | 1 { + if (active === undefined) return 1 + return active === false || (active as unknown) === 'false' ? 0 : 1 +} + export const sendGridCreateTemplateVersionTool: ToolConfig< CreateTemplateVersionParams, TemplateVersionResult @@ -70,7 +75,7 @@ export const sendGridCreateTemplateVersionTool: ToolConfig< const body: SendGridTemplateVersionRequest = { name: params.name, subject: params.subject, - active: params.active !== undefined ? (params.active ? 1 : 0) : 1, + active: toActiveFlag(params.active), } if (params.htmlContent) { From 45fa1ece815405ec9e36fb0856f182c622459df6 Mon Sep 17 00:00:00 2001 From: waleed Date: Thu, 2 Jul 2026 00:42:36 -0700 Subject: [PATCH 06/10] fix(sendgrid): handle numeric 0 in toActiveFlag Per Greptile: the block coerces active to a number (0/1) before calling the tool, but toActiveFlag only checked for false/'false', so the block's inactive selection (0) fell through to the "active" branch. Check against an explicit inactive-values set covering the boolean, string, and numeric forms. --- apps/sim/tools/sendgrid/create_template_version.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/sim/tools/sendgrid/create_template_version.ts b/apps/sim/tools/sendgrid/create_template_version.ts index 18412196c5c..c6fa848f0f4 100644 --- a/apps/sim/tools/sendgrid/create_template_version.ts +++ b/apps/sim/tools/sendgrid/create_template_version.ts @@ -5,9 +5,11 @@ import type { } from '@/tools/sendgrid/types' import type { ToolConfig } from '@/tools/types' +const INACTIVE_VALUES: unknown[] = [false, 'false', 0, '0'] + function toActiveFlag(active: CreateTemplateVersionParams['active']): 0 | 1 { if (active === undefined) return 1 - return active === false || (active as unknown) === 'false' ? 0 : 1 + return INACTIVE_VALUES.includes(active) ? 0 : 1 } export const sendGridCreateTemplateVersionTool: ToolConfig< From 719a9e357da8ae4d3cf0ab049548449a9a8b91a1 Mon Sep 17 00:00:00 2001 From: waleed Date: Thu, 2 Jul 2026 10:01:51 -0700 Subject: [PATCH 07/10] fix(sendgrid): nest add_contact custom fields under custom_fields Pre-existing bug (predates this PR): custom fields were merged onto the contact object as top-level sibling keys via safeAssign/Object.assign, but SendGrid's PUT /v3/marketing/contacts requires them nested under a custom_fields object. SendGrid silently drops unrecognized top-level keys, so the documented customFields param never actually reached SendGrid. Caught during a final adversarial re-verification pass before merge. --- apps/sim/tools/sendgrid/add_contact.ts | 3 +-- apps/sim/tools/sendgrid/types.ts | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/sim/tools/sendgrid/add_contact.ts b/apps/sim/tools/sendgrid/add_contact.ts index 7c273f401eb..7c1a7a37986 100644 --- a/apps/sim/tools/sendgrid/add_contact.ts +++ b/apps/sim/tools/sendgrid/add_contact.ts @@ -1,4 +1,3 @@ -import { safeAssign } from '@/tools/safe-assign' import type { AddContactParams, ContactResult, @@ -73,7 +72,7 @@ export const sendGridAddContactTool: ToolConfig typeof params.customFields === 'string' ? JSON.parse(params.customFields) : params.customFields - safeAssign(contact, customFields as Record) + contact.custom_fields = customFields as Record } const body: SendGridContactRequest = { diff --git a/apps/sim/tools/sendgrid/types.ts b/apps/sim/tools/sendgrid/types.ts index 60e906b7418..fcd0c24ff2d 100644 --- a/apps/sim/tools/sendgrid/types.ts +++ b/apps/sim/tools/sendgrid/types.ts @@ -71,6 +71,7 @@ export interface SendGridContactObject { email: string first_name?: string last_name?: string + custom_fields?: Record [key: string]: unknown } From 151f62de3a6cf4d343fa611161aa67076cf93f6d Mon Sep 17 00:00:00 2001 From: waleed Date: Thu, 2 Jul 2026 10:48:00 -0700 Subject: [PATCH 08/10] fix(sendgrid): document consistent page_size requirement for list_templates pagination Per Cursor Bugbot: list_templates always defaults page_size to 20 when unset (required by SendGrid), so a follow-up pageToken-only call after a first call with a larger pageSize would silently shrink to 20 and desync page boundaries. This is inherent to a stateless tool call (SendGrid requires page_size on every request, and the tool has no way to remember the prior call's value), so clarify via param description and UI placeholder that callers must repeat the same pageSize across paginated calls. --- apps/sim/blocks/blocks/sendgrid.ts | 2 +- apps/sim/tools/sendgrid/list_templates.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/sim/blocks/blocks/sendgrid.ts b/apps/sim/blocks/blocks/sendgrid.ts index fe34410efe3..3ac6efc0c4e 100644 --- a/apps/sim/blocks/blocks/sendgrid.ts +++ b/apps/sim/blocks/blocks/sendgrid.ts @@ -447,7 +447,7 @@ Return ONLY the JSON array.`, id: 'templatePageToken', title: 'Page Token', type: 'short-input', - placeholder: 'Page token from a previous response', + placeholder: 'Page token from a previous response (keep Page Size the same)', condition: { field: 'operation', value: 'list_templates' }, mode: 'advanced', }, diff --git a/apps/sim/tools/sendgrid/list_templates.ts b/apps/sim/tools/sendgrid/list_templates.ts index e2559ab7b0d..90f1c35741e 100644 --- a/apps/sim/tools/sendgrid/list_templates.ts +++ b/apps/sim/tools/sendgrid/list_templates.ts @@ -24,7 +24,10 @@ export const sendGridListTemplatesTool: ToolConfig Date: Thu, 2 Jul 2026 10:53:54 -0700 Subject: [PATCH 09/10] chore(api-validation): bump stale route-count ratchet baseline 883->884 Unrelated to the SendGrid work in this branch. staging's own HEAD already has 884 compliant Zod-backed API routes (0 non-Zod), but this ratchet baseline was never bumped when that route landed, so any PR rebasing onto current staging fails check:api-validation:strict with "route count increased from 883 to 884". All routes remain fully Zod-backed; this is a mechanical counter update, not a policy change. --- scripts/check-api-validation-contracts.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/check-api-validation-contracts.ts b/scripts/check-api-validation-contracts.ts index 80f935786b0..9f5d387d0a1 100644 --- a/scripts/check-api-validation-contracts.ts +++ b/scripts/check-api-validation-contracts.ts @@ -9,8 +9,8 @@ const QUERY_HOOKS_DIR = path.join(ROOT, 'apps/sim/hooks/queries') const SELECTOR_HOOKS_DIR = path.join(ROOT, 'apps/sim/hooks/selectors') const BASELINE = { - totalRoutes: 883, - zodRoutes: 883, + totalRoutes: 884, + zodRoutes: 884, nonZodRoutes: 0, } as const From 4d3663efc15fe973dfa02489a628dbf846640df4 Mon Sep 17 00:00:00 2001 From: waleed Date: Thu, 2 Jul 2026 11:02:18 -0700 Subject: [PATCH 10/10] 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. --- apps/sim/blocks/blocks/sendgrid.ts | 3 ++- apps/sim/tools/sendgrid/create_template_version.ts | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/sim/blocks/blocks/sendgrid.ts b/apps/sim/blocks/blocks/sendgrid.ts index 3ac6efc0c4e..2e68b9c6f15 100644 --- a/apps/sim/blocks/blocks/sendgrid.ts +++ b/apps/sim/blocks/blocks/sendgrid.ts @@ -2,6 +2,7 @@ import { SendgridIcon } from '@/components/icons' import type { BlockConfig, BlockMeta } from '@/blocks/types' import { AuthMode, IntegrationType } from '@/blocks/types' import { normalizeFileInput } from '@/blocks/utils' +import { toActiveFlag } from '@/tools/sendgrid/create_template_version' import type { SendMailResult } from '@/tools/sendgrid/types' export const SendGridBlock: BlockConfig = { @@ -623,7 +624,7 @@ Return ONLY the HTML content.`, ...(operation === 'list_templates' && templatePageToken && { pageToken: templatePageToken }), ...(normalizedAttachments && { attachments: normalizedAttachments }), - ...(active !== undefined && { active: active === 'true' || active === true ? 1 : 0 }), + ...(active !== undefined && { active: toActiveFlag(active) }), } }, }, diff --git a/apps/sim/tools/sendgrid/create_template_version.ts b/apps/sim/tools/sendgrid/create_template_version.ts index c6fa848f0f4..23267575d8b 100644 --- a/apps/sim/tools/sendgrid/create_template_version.ts +++ b/apps/sim/tools/sendgrid/create_template_version.ts @@ -7,7 +7,10 @@ import type { ToolConfig } from '@/tools/types' const INACTIVE_VALUES: unknown[] = [false, 'false', 0, '0'] -function toActiveFlag(active: CreateTemplateVersionParams['active']): 0 | 1 { +/** Coerces any dynamic-reference form of SendGrid's active flag (boolean, string, or + * number) to the 0/1 integer the API requires. Shared with the block's own + * pre-coercion in blocks/blocks/sendgrid.ts so both layers stay in sync. */ +export function toActiveFlag(active: unknown): 0 | 1 { if (active === undefined) return 1 return INACTIVE_VALUES.includes(active) ? 0 : 1 }