:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(workflows): support templated From overrides in email steps (#83059)
Harley Alexander77b367bdba2f
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 6d68b5bc61c0..2df8f7416249 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -6653,7 +6653,7 @@ snapshots:scenes-app-insights-error-empty-states--memory-limit-exceeded--light:hash: v1.k794b7964.5db627722825a5e96b5c9a60b66b003822ef339c07c8cb0475bbe726df99a14b.wl_oFPQ_LwRebMnu1nHg-LQxBV-L9Q5nRkkKxr3gH9gscenes-app-insights-error-empty-states--query-server-error--dark:- hash: v1.k794b7964.5e0a4f13fb00ef944649228004095f84fd1d859bd66cdd5ec9e25bd745d6828d.k4NYuOAkHqlOwwSIUSHJiywF8FxVwqlIbahs9NdgpF4+ hash: v1.k794b7964.c30da1434c9c4cfc8ea0e808803370c4d9f77c38f1758dfdb4840ab58def1675.V7oqqsPrl1k8BBlI9jTHhj9KZ_LkWDGixSpg3GhFXv8scenes-app-insights-error-empty-states--query-server-error--light:hash: v1.k794b7964.8cbd2901888aa723067ddea0dc2c6045628c0cb872438beca4e667592d25aaf6.4GmhzW21hmldOgELAwHy522bovvzkaq8b4i0NowPhb8scenes-app-insights-error-empty-states--server-error--dark:diff --git a/frontend/src/lib/components/CyclotronJob/CyclotronJobInputsValidation.test.ts b/frontend/src/lib/components/CyclotronJob/CyclotronJobInputsValidation.test.tsindex ed884bae85b9..c537cf44421a 100644--- a/frontend/src/lib/components/CyclotronJob/CyclotronJobInputsValidation.test.ts+++ b/frontend/src/lib/components/CyclotronJob/CyclotronJobInputsValidation.test.ts@@ -252,6 +252,40 @@ describe('CyclotronJobInputsValidation', () => {})})+ describe('native_email From overrides (object form)', () => {+ // native_email stores `from` as { integrationId, email?, name? } where the optional+ // keys are templated sender overrides resolved per invocation.+ const nativeEmailInput = (from: unknown): Record<string, CyclotronJobInputType> => ({+ email: {+ templating: 'liquid',+ value: { html: '<p>Hi</p>', subject: 'Subject', from, to: { name: '', email: '[email protected]' } },+ },+ })+ const schema: CyclotronJobInputSchemaType[] = [{ key: 'email', type: 'native_email', label: 'Email' }]++ it.each([+ ['from.email', { integrationId: 1, email: '{{ event.properties.sender' }],+ ['from.name', { integrationId: 1, name: '{{ event.properties.sender' }],+ ])('errors on a malformed Liquid template in %s', (_desc, from) => {+ const result = CyclotronJobInputsValidation.validate(nativeEmailInput(from), schema)+ expect(result.valid).toBe(false)+ expect(result.errors.email).toContain('Liquid template error')+ })++ it('passes valid Liquid templates in the from overrides', () => {+ const result = CyclotronJobInputsValidation.validate(+ nativeEmailInput({+ integrationId: 1,+ email: '{{ event.properties.sender_email }}',+ name: '{{ event.properties.sender_name }}',+ }),+ schema+ )+ expect(result.valid).toBe(true)+ expect(result.errors).toEqual({})+ })+ })+describe('templating validation', () => {it('should validate liquid templates and return error on parse failure', () => {const inputs = { template: { value: '{% invalid %}', templating: 'liquid' as const } }diff --git a/frontend/src/lib/components/CyclotronJob/CyclotronJobInputsValidation.ts b/frontend/src/lib/components/CyclotronJob/CyclotronJobInputsValidation.tsindex 306a3f6e41ee..c188e3e2b9a6 100644--- a/frontend/src/lib/components/CyclotronJob/CyclotronJobInputsValidation.ts+++ b/frontend/src/lib/components/CyclotronJob/CyclotronJobInputsValidation.ts@@ -164,7 +164,13 @@ const validateInput = (input: CyclotronJobInputType, inputSchema: CyclotronJobIn: undefined,text: value.text ? getTemplatingError(value.text) : undefined,subject: !value.subject ? 'Subject is required' : getTemplatingError(value.subject),- from: !value.from ? 'From is required' : getTemplatingError(value.from),+ // `native_email` stores `from` as { integrationId, email?, name? } where the optional+ // keys are templated sender overrides; the legacy `email` type stores a template string.+ from: !value.from+ ? 'From is required'+ : typeof value.from === 'string'+ ? getTemplatingError(value.from)+ : (getTemplatingError(value.from.email) ?? getTemplatingError(value.from.name)),to: !toEmail ? 'To is required' : getTemplatingError(toEmail),}diff --git a/frontend/src/scenes/hog-functions/email-templater/EmailTemplater.tsx b/frontend/src/scenes/hog-functions/email-templater/EmailTemplater.tsxindex bfb8f84fad7c..53a95cf58151 100644--- a/frontend/src/scenes/hog-functions/email-templater/EmailTemplater.tsx+++ b/frontend/src/scenes/hog-functions/email-templater/EmailTemplater.tsx@@ -26,7 +26,7 @@ import { MessageTemplateCard } from 'products/workflows/frontend/TemplateLibraryimport { collapseToolsPanelCustomJs } from './custom-tools/collapseToolsPanel'import { unsubscribeLinkToolCustomJs } from './custom-tools/unsubscribeLinkTool'import { EMAIL_TYPE_SUPPORTED_FIELDS, EmailTemplaterLogicProps, emailTemplaterLogic } from './emailTemplaterLogic'-import { EmailFieldErrors } from './types'+import { EmailFieldErrors, EmailTemplateFrom } from './types'export type EmailEditorMode = 'full' | 'preview'@@ -233,73 +233,139 @@ function DestinationEmailTemplaterForm({}function NativeEmailIntegrationChoice({+ label,onChange,value,}: {- onChange: (value: any) => void- value: any+ /** Rendered inside the sender row so it aligns with the select rather than spanning the override rows. */+ label: ReactNode+ onChange: (value: EmailTemplateFrom) => void+ value?: EmailTemplateFrom}): JSX.Element {const { integrationsLoading, integrations } = useValues(integrationsLogic)+ const { logicProps } = useValues(emailTemplaterLogic)const integrationsOfKind = integrations?.filter((x) => x.kind === 'email')+ // Presence of the override keys is what reveals the inputs, so a saved override is+ // visible again on reopen without any separate reveal state.+ const overridesVisible = value?.email !== undefined || value?.name !== undefined+const onChangeIntegration = (integrationId: number): void => {if (integrationId === -1) {// Open new integration modalwindow.open(urls.workflows('channels'), '_blank')return}- onChange({ integrationId })+ onChange({ ...value, integrationId })}if (!integrationsLoading && integrationsOfKind?.length === 0) {return (- <div className="flex gap-2 justify-end items-center">- <span className="text-muted">No email senders configured yet</span>- <LemonButton- size="small"- type="tertiary"- to={urls.workflows('channels')}- targetBlank- className="m-1"- icon={<IconExternal />}- >- Connect email sender- </LemonButton>+ <div className="flex gap-2 justify-between items-center">+ {label}+ <div className="flex gap-2 items-center">+ <span className="text-muted">No email senders configured yet</span>+ <LemonButton+ size="small"+ type="tertiary"+ to={urls.workflows('channels')}+ targetBlank+ className="m-1"+ icon={<IconExternal />}+ >+ Connect email sender+ </LemonButton>+ </div></div>)}return (- <>- <LemonSelect- className="m-1 flex-1"- type="tertiary"- placeholder="Choose email sender"- loading={integrationsLoading}- options={[- {- title: 'Email senders',- options: (integrationsOfKind || []).map((integration) => ({- label: integration.display_name,- value: integration.id,- })),- },- {- options: [- {- label: 'Add new email sender',- icon: <IconExternal />,- value: -1,- },- ],- },- ]}- value={value?.integrationId}- size="small"- fullWidth- onChange={onChangeIntegration}- />- </>+ <div className="flex flex-col">+ <div className="flex gap-2 items-center">+ {label}+ <LemonSelect+ className="m-1 flex-1"+ type="tertiary"+ placeholder="Choose email sender"+ loading={integrationsLoading}+ options={[+ {+ title: 'Email senders',+ options: (integrationsOfKind || []).map((integration) => ({+ label: integration.display_name,+ value: integration.id,+ })),+ },+ {+ options: [+ {+ label: 'Add new email sender',+ icon: <IconExternal />,+ value: -1,+ },+ ],+ },+ ]}+ value={value?.integrationId}+ size="small"+ fullWidth+ onChange={onChangeIntegration}+ />+ {!overridesVisible && (+ <LemonButton+ size="xsmall"+ type="secondary"+ icon={<IconPlus />}+ className="mr-2 shrink-0"+ data-attr="email-from-custom-sender"+ onClick={() => onChange({ ...value, email: '', name: '' })}+ tooltip="Set a custom sender address or name, with template support"+ >+ Custom sender+ </LemonButton>+ )}+ </div>+ {overridesVisible && (+ <>+ <div className="flex gap-2 items-center border-t">+ <LemonLabel+ className="min-w-30 shrink-0"+ info="The address to send from. Templates are supported, so the address can come from the triggering event. It must be on the selected sender's verified domain. Leave empty to use the sender's address."+ >+ Custom address+ </LemonLabel>+ <LiquidSupportedText+ value={value?.email ?? ''}+ onChange={(email) => onChange({ ...value, email })}+ globals={logicProps.variables}+ />+ <LemonButton+ size="xsmall"+ type="tertiary"+ icon={<IconX />}+ className="mr-2"+ data-attr="email-from-custom-sender-remove"+ onClick={() => onChange({ integrationId: value?.integrationId })}+ tooltip="Remove custom sender"+ />+ </div>+ <div className="flex gap-2 items-center border-t">+ <LemonLabel+ className="min-w-30 shrink-0"+ info="The sender name shown in the recipient's inbox. Templates are supported. Leave empty to use the sender's name."+ >+ Custom name+ </LemonLabel>+ <LiquidSupportedText+ value={value?.name ?? ''}+ onChange={(name) => onChange({ ...value, name })}+ globals={logicProps.variables}+ />+ </div>+ </>+ )}+ </div>)}@@ -476,8 +542,8 @@ function NativeEmailTemplaterForm({renderError={() => null}showOptional={field.optional}>- {({ value, onChange }: ChildFunctionProps) => (- <div className="flex gap-2 items-center">+ {({ value, onChange }: ChildFunctionProps) => {+ const label = (<LemonLabelclassName={fieldError ? 'text-danger' : ''}info={field.helpText}@@ -485,40 +551,49 @@ function NativeEmailTemplaterForm({>{field.label}</LemonLabel>- {field.key === 'from' ? (- <NativeEmailIntegrationChoice value={value} onChange={onChange} />- ) : field.key === 'to' ? (- /**- * In email inputs, "to" maps to { email: string; name: string; },- * whereas other fields map directly to their string value- */- <LiquidSupportedText- value={value?.email}- onChange={(email) => onChange({ ...value, email })}- globals={logicProps.variables}- />- ) : (- <LiquidSupportedText- value={value}- onChange={onChange}- globals={logicProps.variables}- />- )}- {field.isAdvancedField && (- <LemonButton- size="xsmall"- type="tertiary"- icon={<IconX />}- className="mr-2"- onClick={() => {- onChange('')- hideAdvancedField(field.key)- }}- tooltip="Remove field"- />- )}- </div>- )}+ )+ return field.key === 'from' ? (+ <NativeEmailIntegrationChoice+ label={label}+ value={value}+ onChange={onChange}+ />+ ) : (+ <div className="flex gap-2 items-center">+ {label}+ {field.key === 'to' ? (+ /**+ * In email inputs, "to" maps to { email: string; name: string; },+ * whereas other fields map directly to their string value+ */+ <LiquidSupportedText+ value={value?.email}+ onChange={(email) => onChange({ ...value, email })}+ globals={logicProps.variables}+ />+ ) : (+ <LiquidSupportedText+ value={value}+ onChange={onChange}+ globals={logicProps.variables}+ />+ )}+ {field.isAdvancedField && (+ <LemonButton+ size="xsmall"+ type="tertiary"+ icon={<IconX />}+ className="mr-2"+ onClick={() => {+ onChange('')+ hideAdvancedField(field.key)+ }}+ tooltip="Remove field"+ />+ )}+ </div>+ )+ }}</LemonField><FieldErrorMessage error={fieldError} /></div>diff --git a/frontend/src/scenes/hog-functions/email-templater/types.ts b/frontend/src/scenes/hog-functions/email-templater/types.tsindex 17632360739f..404e39c4c184 100644--- a/frontend/src/scenes/hog-functions/email-templater/types.ts+++ b/frontend/src/scenes/hog-functions/email-templater/types.ts@@ -2,12 +2,22 @@ import { Editor } from 'react-email-editor'type JSONTemplate = Parameters<Editor['loadDesign']>[0]+// The native email sender: the integration pins the verified domain, while the optional+// templated overrides let a single workflow vary the sender per invocation. The runtime+// rejects an override address that is not on the integration's verified domain.+export type EmailTemplateFrom = {+ integrationId?: number+ email?: string+ name?: string+}+export type EmailTemplate = {design: JSONTemplate | nullhtml: stringsubject: stringtext: string- from: string+ // A bare template string for legacy `email` inputs; an EmailTemplateFrom for `native_email`.+ from: string | EmailTemplateFromto: stringreplyTo?: stringcc?: stringdiff --git a/nodejs/src/cdp/schema/cyclotron.ts b/nodejs/src/cdp/schema/cyclotron.tsindex 2611234307d8..ae397cf9df6b 100644--- a/nodejs/src/cdp/schema/cyclotron.ts+++ b/nodejs/src/cdp/schema/cyclotron.ts@@ -131,6 +131,10 @@ export const CyclotronInvocationQueueParametersEmailSchema = z.object({replyTo: z.string().optional(),from: z.object({integrationId: z.number(),+ // Templated per-invocation sender overrides. EmailService requires the rendered+ // address to be on the integration's verified domain before it reaches the provider.+ email: z.string().optional(),+ name: z.string().optional(),}),cc: z.string().optional(),bcc: z.string().optional(),diff --git a/nodejs/src/cdp/services/messaging/email.service.test.ts b/nodejs/src/cdp/services/messaging/email.service.test.tsindex 2eb6c1f79be3..ed75cb01392b 100644--- a/nodejs/src/cdp/services/messaging/email.service.test.ts+++ b/nodejs/src/cdp/services/messaging/email.service.test.ts@@ -251,6 +251,65 @@ describe('EmailService', () => {expect(result.error).toBeUndefined()})})+ describe('from overrides', () => {+ it.each<[string, { email?: string; name?: string }, string, string]>([+ [+ 'address on the verified domain',+ { email: '[email protected]' },+ '"Test User" <[email protected]>',+ '[email protected]',+ ],+ [+ 'address with different domain casing',+ { email: '[email protected]' },+ '"Test User" <[email protected]>',+ '[email protected]',+ ],+ ['name only', { name: 'Community Team' }, '"Community Team" <[email protected]>', '[email protected]'],+ [+ 'name and address',+ { email: '[email protected]', name: 'Community Team' },+ '"Community Team" <[email protected]>',+ '[email protected]',+ ],+ [+ 'empty overrides fall back to the integration sender',+ { email: '', name: '' },+ '"Test User" <[email protected]>',+ '[email protected]',+ ],+ [+ 'name with header-breaking characters is sanitized',+ { name: '"Evil" <[email protected]>,\r\n Bcc:' },+ '"Evil [email protected], Bcc:" <[email protected]>',+ '[email protected]',+ ],+ ])('applies the %s', async (_desc, fromOverride, expectedFrom, expectedFeedback) => {+ invocation.queueParameters = createEmailParams({+ from: { integrationId: 1, ...fromOverride },+ })+ const result = await service.executeSendEmail(invocation)+ expect(result.error).toBeUndefined()+ const sentCommand = sendEmailSpy.mock.calls[0][0] as { input: any }+ expect(sentCommand.input.FromEmailAddress).toBe(expectedFrom)+ expect(sentCommand.input.FeedbackForwardingEmailAddress).toBe(expectedFeedback)+ })++ it.each([+ ['an address on an unverified domain', '[email protected]'],+ ['an address on a subdomain of the verified domain', '[email protected]'],+ ['a list of addresses', '[email protected], [email protected]'],+ ['an RFC-822 formatted address', '"Name" <[email protected]>'],+ ['a value that is not an email address', 'not-an-email'],+ ])('rejects %s without calling SES', async (_desc, email) => {+ invocation.queueParameters = createEmailParams({+ from: { integrationId: 1, email },+ })+ const result = await service.executeSendEmail(invocation)+ expect(result.error).toContain(`"${email}"`)+ expect(sendEmailSpy).not.toHaveBeenCalled()+ })+ })describe('email sending', () => {it('should send an email', async () => {const result = await service.executeSendEmail(invocation)diff --git a/nodejs/src/cdp/services/messaging/email.service.ts b/nodejs/src/cdp/services/messaging/email.service.tsindex ba179c0f688f..3b54feff8504 100644--- a/nodejs/src/cdp/services/messaging/email.service.ts+++ b/nodejs/src/cdp/services/messaging/email.service.ts@@ -120,6 +120,17 @@ export function extractEmailsFromAddressList(value: string | undefined): string[.filter((addr) => addr.length > 0)}+// Deliberately stricter than RFC 5322: exactly one @, a dotted domain, and none of the+// characters that would let a templated value smuggle a second address or break out of the+// RFC-822 `"Name" <email>` framing (whitespace, quotes, angle brackets, list separators).+const FROM_OVERRIDE_EMAIL_REGEX = /^[^\s@"<>,;]+@[^\s@"<>,;]+\.[^\s@"<>,;]+$/++// The display name is embedded as `"${name}" <email>`, so strip the characters that would+// terminate the quoted phrase or start the address part, plus control characters.+function sanitizeFromName(name: string): string {+ return name.replace(/[\x00-\x1F\x7F"<>\\]/g, '').trim()+}+export function parseAddressList(value?: string): string[] | undefined {if (!value || !value.trim()) {return undefined@@ -217,7 +228,7 @@ export class EmailService {)}- const from = this.resolveFromSender(integration)+ const from = this.resolveFromSender(integration, params.from)// Single choke point for the suppression check — every send path lands here regardless// of whether the invocation came from a workflow action or an email destination hog@@ -465,7 +476,10 @@ export class EmailService {return this.sesConfig.sesTrackedConfigurationSet}- private resolveFromSender(integration: IntegrationType): { email: string; name: string } {+ private resolveFromSender(+ integration: IntegrationType,+ from: CyclotronInvocationQueueParametersEmailType['from']+ ): { email: string; name: string } {if (!integration.config.verified) {throw new Error('The selected email integration domain is not verified')}@@ -474,7 +488,44 @@ export class EmailService {throw new Error('The selected email integration is not configured correctly')}- return { email: integration.config.email, name: integration.config.name }+ // Overrides arrive already rendered by the templating engine, so a template that+ // resolved to nothing means "no override" and the integration's stored sender applies.+ const overrideName = from.name ? sanitizeFromName(from.name) : ''++ return {+ email: this.resolveFromEmailAddress(integration, from.email?.trim()),+ name: overrideName || integration.config.name,+ }+ }++ private resolveFromEmailAddress(integration: IntegrationType, overrideEmail: string | undefined): string {+ if (!overrideEmail) {+ return integration.config.email+ }++ if (!FROM_OVERRIDE_EMAIL_REGEX.test(overrideEmail)) {+ throw new Error(+ `The custom sender address "${overrideEmail}" is not a valid email address. Fix the From address in the workflow's email step so it resolves to a single valid address.`+ )+ }++ // Verification is domain-level (the DNS records cover the whole domain), so any address+ // on the integration's domain is exactly as verified as the integration's own address.+ // Anything off-domain must fail: allowing it would let a workflow send as a domain the+ // team never proved ownership of.+ const integrationDomain: string = (+ integration.config.domain ??+ integration.config.email.split('@')[1] ??+ ''+ ).toLowerCase()+ const overrideDomain = overrideEmail.split('@')[1].toLowerCase()+ if (!integrationDomain || overrideDomain !== integrationDomain) {+ throw new Error(+ `The custom sender address "${overrideEmail}" is not on the verified domain "${integrationDomain}" of the selected sender. Use an address on that domain, or select a different sender in the workflow's email step.`+ )+ }++ return overrideEmail}// Send email to local maildev instance for testing (DEBUG=1 only)diff --git a/posthog/cdp/test/test_validation.py b/posthog/cdp/test/test_validation.pyindex 3f7987b0b8cd..9f21d11a4e0c 100644--- a/posthog/cdp/test/test_validation.py+++ b/posthog/cdp/test/test_validation.py@@ -497,6 +497,47 @@ class TestHogFunctionValidation(ClickhouseTestMixin, APIBaseTest, QueryMatchingTvalidate_inputs(inputs_schema, inputs)assert expected in str(ctx.value.detail)+ @parameterized.expand(+ [+ ("email_not_a_string", {"email": 123}, "Expected string value for 'from.email'."),+ (+ "both_not_strings",+ {"email": 123, "name": ["x"]},+ "Expected string values for 'from.email', 'from.name'.",+ ),+ ]+ )+ def test_email_from_overrides_must_be_strings(self, _name, overrides, expected):+ # A non-string override saves fine without this check and then fails every send in the+ # runtime's schema parse, so the shape error must surface at authoring time instead.+ inputs_schema = [{"key": "email", "type": "native_email", "required": True, "templating": "liquid"}]+ value = {+ "from": {"integrationId": 1, **overrides},+ "to": "[email protected]",+ "subject": "hi",+ "text": "hi",+ }++ with pytest.raises(ValidationError) as ctx:+ validate_inputs(inputs_schema, {"email": {"value": value}})+ assert expected in str(ctx.value.detail)++ def test_email_from_overrides_accept_templated_strings(self):+ inputs_schema = [{"key": "email", "type": "native_email", "required": True, "templating": "liquid"}]+ value = {+ "from": {"integrationId": 1, "email": "{{ event.properties.sender_email }}", "name": "Community"},+ "to": "[email protected]",+ "subject": "hi",+ "text": "hi",+ }++ validated = validate_inputs(inputs_schema, {"email": {"value": value}})+ assert validated["email"]["value"]["from"] == {+ "integrationId": 1,+ "email": "{{ event.properties.sender_email }}",+ "name": "Community",+ }+@parameterized.expand([("person", "{person?.id}"),diff --git a/posthog/cdp/validation.py b/posthog/cdp/validation.pyindex 472a6392e9dd..5d664947557d 100644--- a/posthog/cdp/validation.py+++ b/posthog/cdp/validation.py@@ -470,6 +470,21 @@ class InputsItemSerializer(serializers.Serializer):label = "value" if len(missing) == 1 else "values"raise serializers.ValidationError({"input": f"Missing {label} for {', '.join(missing)}."})+ # Templated sender overrides on the `from` object. Non-string values would only+ # surface as a send-time failure in the runtime's schema parse, so reject them here.+ from_value = value.get("from")+ if isinstance(from_value, dict):+ wrong_types = [+ f"'from.{key_}'"+ for key_ in ("email", "name")+ if from_value.get(key_) is not None and not isinstance(from_value[key_], str)+ ]+ if wrong_types:+ label = "value" if len(wrong_types) == 1 else "values"+ raise serializers.ValidationError(+ {"input": f"Expected string {label} for {', '.join(wrong_types)}."}+ )+if isinstance(value.get("html"), str) and value["html"] and not value.get("design"):# Programmatically authored emails often supply html without a design, which the# visual editor can't open. Wrap it so every stored email has an editable design.diff --git a/products/workflows/backend/api/hog_flow.py b/products/workflows/backend/api/hog_flow.pyindex 0161a25b9c99..f3b6ed4a001c 100644--- a/products/workflows/backend/api/hog_flow.py+++ b/products/workflows/backend/api/hog_flow.py@@ -2278,8 +2278,10 @@ class HogFlowActionEmailUpdateSerializer(serializers.Serializer):required=False,help_text=("Partial email fields deep-merged into the step's email (a null leaf deletes the key): subject, "- "preheader, text, to, from, replyTo, cc, bcc. The design is edited via operations, and html is "- "always re-rendered from it."+ "preheader, text, to, from, replyTo, cc, bcc. The sender is from: {integrationId, email?, name?}, "+ "where email and name are optional templated overrides resolved per invocation; the address must "+ "resolve to the selected sender's verified domain or the send fails. The design is edited via "+ "operations, and html is always re-rendered from it."),)diff --git a/products/workflows/frontend/Workflows/workflowLogic.emailValidation.test.ts b/products/workflows/frontend/Workflows/workflowLogic.emailValidation.test.tsindex 485417102304..aca184f45e45 100644--- a/products/workflows/frontend/Workflows/workflowLogic.emailValidation.test.ts+++ b/products/workflows/frontend/Workflows/workflowLogic.emailValidation.test.ts@@ -204,10 +204,14 @@ describe('workflowLogic email step "from" validation', () => {expect(result?.errors.email).toBeUndefined()})- it('does not flag a "from" error when an integration sender has been picked', async () => {+ it('does not flag a "from" error when a sender is picked, including valid templated overrides', async () => {useMocks({get: {- '/api/environments/:team_id/hog_flows/:id/': makeWorkflow({ integrationId: 42 }),+ '/api/environments/:team_id/hog_flows/:id/': makeWorkflow({+ integrationId: 42,+ email: '{{ event.properties.sender_email }}',+ name: 'Community team',+ }),'/api/projects/:team_id/hog_function_templates/': hangingTemplatesEndpoint,},})@@ -221,6 +225,28 @@ describe('workflowLogic email step "from" validation', () => {expect(result?.valid).toBe(true)})+ it('flags a broken Liquid template in the custom sender fields once a save is attempted', async () => {+ useMocks({+ get: {+ '/api/environments/:team_id/hog_flows/:id/': makeWorkflow({+ integrationId: 42,+ email: '{{ event.properties.sender',+ }),+ '/api/projects/:team_id/hog_function_templates/': hangingTemplatesEndpoint,+ },+ })+ initKeaTests()+ logic = workflowLogic({ id: WORKFLOW_ID })+ logic.mount()+ await expectLogic(logic).toDispatchActions(['loadWorkflowSuccess'])++ logic.actions.saveWorkflowPartial({ status: 'active' })++ const result = logic.values.actionValidationErrorsById[EMAIL_NODE_ID]+ expect(result?.valid).toBe(false)+ expect(result?.emailErrors?.from).toContain('Liquid template error')+ })+it('keeps the step invalid after templates load (generic validator must not resurface a blob)', async () => {useMocks({get: {diff --git a/products/workflows/frontend/Workflows/workflowLogic.ts b/products/workflows/frontend/Workflows/workflowLogic.tsindex d086d9b439cc..501be602200d 100644--- a/products/workflows/frontend/Workflows/workflowLogic.ts+++ b/products/workflows/frontend/Workflows/workflowLogic.ts@@ -3286,7 +3286,8 @@ export const workflowLogic = kea<workflowLogicType>([: getTemplatingError(emailValue?.subject, emailTemplating),from: !emailValue?.from?.integrationId? 'Choose an email sender, or connect a new one'- : undefined,+ : (getTemplatingError(emailValue?.from?.email, emailTemplating) ??+ getTemplatingError(emailValue?.from?.name, emailTemplating)),to: !emailValue?.to?.email? 'Add a recipient': getTemplatingError(emailValue?.to?.email, emailTemplating),diff --git a/products/workflows/frontend/generated/api.schemas.ts b/products/workflows/frontend/generated/api.schemas.tsindex 374648893982..afd964a3f509 100644--- a/products/workflows/frontend/generated/api.schemas.ts+++ b/products/workflows/frontend/generated/api.schemas.ts@@ -723,7 +723,7 @@ export interface PatchedHogFlowActionEmailUpdateApi {base_updated_at?: string/** Ordered design edits applied atomically to this step's email design - the same operations as the email template patch. The result is re-rendered to HTML server-side, so the sent email always matches the patched design. */operations?: DesignOperationApi[]- /** Partial email fields deep-merged into the step's email (a null leaf deletes the key): subject, preheader, text, to, from, replyTo, cc, bcc. The design is edited via operations, and html is always re-rendered from it. */+ /** Partial email fields deep-merged into the step's email (a null leaf deletes the key): subject, preheader, text, to, from, replyTo, cc, bcc. The sender is from: {integrationId, email?, name?}, where email and name are optional templated overrides resolved per invocation; the address must resolve to the selected sender's verified domain or the send fails. The design is edited via operations, and html is always re-rendered from it. */email_patch?: unknown}diff --git a/products/workflows/frontend/generated/api.zod.ts b/products/workflows/frontend/generated/api.zod.tsindex cd97a9fd0d4f..40d5840e074b 100644--- a/products/workflows/frontend/generated/api.zod.ts+++ b/products/workflows/frontend/generated/api.zod.ts@@ -1490,7 +1490,7 @@ export const HogFlowsActionsEmailPartialUpdateBody = /* @__PURE__ */ zod.object(.unknown().optional().describe(- "Partial email fields deep-merged into the step's email (a null leaf deletes the key): subject, preheader, text, to, from, replyTo, cc, bcc. The design is edited via operations, and html is always re-rendered from it."+ "Partial email fields deep-merged into the step's email (a null leaf deletes the key): subject, preheader, text, to, from, replyTo, cc, bcc. The sender is from: {integrationId, email?, name?}, where email and name are optional templated overrides resolved per invocation; the address must resolve to the selected sender's verified domain or the send fails. The design is edited via operations, and html is always re-rendered from it."),})diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex a20710ddf653..d85c8d1f6fc5 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -57179,7 +57179,7 @@ export namespace Schemas {base_updated_at?: string;/** Ordered design edits applied atomically to this step's email design - the same operations as the email template patch. The result is re-rendered to HTML server-side, so the sent email always matches the patched design. */operations?: DesignOperation[];- /** Partial email fields deep-merged into the step's email (a null leaf deletes the key): subject, preheader, text, to, from, replyTo, cc, bcc. The design is edited via operations, and html is always re-rendered from it. */+ /** Partial email fields deep-merged into the step's email (a null leaf deletes the key): subject, preheader, text, to, from, replyTo, cc, bcc. The sender is from: {integrationId, email?, name?}, where email and name are optional templated overrides resolved per invocation; the address must resolve to the selected sender's verified domain or the send fails. The design is edited via operations, and html is always re-rendered from it. */email_patch?: unknown;}diff --git a/services/mcp/src/generated/workflows/api.ts b/services/mcp/src/generated/workflows/api.tsindex 36090ae90e1a..d1a42f1f5a41 100644--- a/services/mcp/src/generated/workflows/api.ts+++ b/services/mcp/src/generated/workflows/api.ts@@ -601,7 +601,7 @@ export const HogFlowsActionsEmailPartialUpdateBody = /* @__PURE__ */ zod.object(.unknown().optional().describe(- "Partial email fields deep-merged into the step's email (a null leaf deletes the key): subject, preheader, text, to, from, replyTo, cc, bcc. The design is edited via operations, and html is always re-rendered from it."+ "Partial email fields deep-merged into the step's email (a null leaf deletes the key): subject, preheader, text, to, from, replyTo, cc, bcc. The sender is from: {integrationId, email?, name?}, where email and name are optional templated overrides resolved per invocation; the address must resolve to the selected sender's verified domain or the send fails. The design is edited via operations, and html is always re-rendered from it."),})