Skip to content

Commit f8e2cc6

Browse files
fix(workflows): remove duplicate run email metadata
1 parent 68572ce commit f8e2cc6

9 files changed

Lines changed: 15 additions & 34 deletions

File tree

apps/sim/blocks/blocks/start_trigger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const StartTriggerBlock: BlockConfig = {
3232
mode: 'advanced',
3333
defaultValue: false,
3434
description:
35-
'Expose trusted, server-injected run metadata under <start.metadata>: subject, userEmail, workspaceId, workflowId, executionId, executionType, executionMode, startTime. The subject identifies the authenticated Sim user, chat email, or external provider user without exposing credentials.',
35+
'Expose trusted, server-injected run metadata under <start.metadata>: subject, workspaceId, workflowId, executionId, executionType, executionMode, startTime. The subject identifies the authenticated Sim user, chat email, or external provider user without exposing credentials.',
3636
},
3737
],
3838
tools: {

apps/sim/executor/handlers/workflow/workflow-handler.test.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,6 @@ describe('WorkflowBlockHandler', () => {
749749
userId: 'consumer-1',
750750
email: 'a@corp.com',
751751
},
752-
userEmail: 'a@corp.com',
753752
workspaceId: 'workspace-consumer',
754753
workflowId: 'parent-workflow-id',
755754
executionId: 'exec-1',
@@ -772,7 +771,6 @@ describe('WorkflowBlockHandler', () => {
772771
userId: 'original-user',
773772
email: 'original@corp.com',
774773
},
775-
userEmail: 'original@corp.com',
776774
workspaceId: 'workspace-original',
777775
workflowId: 'workflow-original',
778776
executionId: 'exec-1',
@@ -857,7 +855,6 @@ describe('WorkflowBlockHandler', () => {
857855
userId: 'original-user',
858856
email: 'original@corp.com',
859857
},
860-
userEmail: 'original@corp.com',
861858
workspaceId: 'workspace-original',
862859
workflowId: 'workflow-original',
863860
executionMode: 'async',
@@ -872,7 +869,6 @@ describe('WorkflowBlockHandler', () => {
872869
workspaceId: 'workspace-parent',
873870
startRunMetadata: {
874871
subject: null,
875-
userEmail: null,
876872
workspaceId: 'workspace-original',
877873
workflowId: 'workflow-original',
878874
},
@@ -913,7 +909,6 @@ describe('WorkflowBlockHandler', () => {
913909

914910
expect(executorOptions).toHaveLength(1)
915911
expect(executorOptions[0].contextExtensions.startRunMetadata.subject).toBeNull()
916-
expect(executorOptions[0].contextExtensions.startRunMetadata.userEmail).toBeNull()
917912
expect(mockGetUserEmailById).not.toHaveBeenCalled()
918913
})
919914

@@ -923,7 +918,6 @@ describe('WorkflowBlockHandler', () => {
923918
kind: 'authenticated_email' as const,
924919
email: 'original@corp.com',
925920
},
926-
userEmail: 'original@corp.com',
927921
workspaceId: 'workspace-original',
928922
workflowId: 'workflow-original',
929923
executionMode: 'sync',
@@ -989,7 +983,6 @@ describe('WorkflowBlockHandler', () => {
989983
kind: 'authenticated_email',
990984
email: 'original@corp.com',
991985
},
992-
userEmail: 'original@corp.com',
993986
workspaceId: 'workspace-original',
994987
workflowId: 'workflow-original',
995988
})
@@ -1002,7 +995,6 @@ describe('WorkflowBlockHandler', () => {
1002995
kind: 'authenticated_email' as const,
1003996
email: 'original@corp.com',
1004997
},
1005-
userEmail: 'original@corp.com',
1006998
workspaceId: 'workspace-original',
1007999
workflowId: 'workflow-original',
10081000
}

apps/sim/executor/handlers/workflow/workflow-handler.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,6 @@ export class WorkflowBlockHandler implements BlockHandler {
675675
if (inherited && Object.hasOwn(inherited, 'subject')) {
676676
invokingIdentity = {
677677
subject: inherited.subject ?? null,
678-
userEmail: inherited.userEmail ?? null,
679678
}
680679
} else {
681680
if (!ctx.principal) {

apps/sim/executor/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ export type StartBlockRunSubject =
263263
*/
264264
export interface StartBlockRunMetadata {
265265
subject?: StartBlockRunSubject | null
266-
userEmail?: string | null
267266
workspaceId?: string | null
268267
workflowId?: string | null
269268
executionId?: string

apps/sim/executor/utils/start-block.test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,6 @@ describe('start-block utilities', () => {
853853
userId: 'user-1',
854854
email: 'real@sim.ai',
855855
},
856-
userEmail: 'real@sim.ai',
857856
workspaceId: 'ws-1',
858857
workflowId: 'wf-1',
859858
executionId: 'exec-1',
@@ -877,7 +876,9 @@ describe('start-block utilities', () => {
877876
const output = buildStartBlockOutput({
878877
resolution,
879878
workflowInput: {
880-
metadata: { userEmail: 'attacker@x.com' },
879+
metadata: {
880+
subject: { kind: 'authenticated_email', email: 'attacker@x.com' },
881+
},
881882
simUserEmail: 'attacker@x.com',
882883
payload: 'value',
883884
},
@@ -894,7 +895,11 @@ describe('start-block utilities', () => {
894895

895896
const output = buildStartBlockOutput({
896897
resolution,
897-
workflowInput: { metadata: { userEmail: 'attacker@x.com' } },
898+
workflowInput: {
899+
metadata: {
900+
subject: { kind: 'authenticated_email', email: 'attacker@x.com' },
901+
},
902+
},
898903
})
899904

900905
expect(output).not.toHaveProperty('metadata')

apps/sim/lib/workflows/blocks/block-outputs.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,9 @@ describe('block outputs parity', () => {
8585
expect(paths).toContain('metadata.subject.provider')
8686
expect(paths).toContain('metadata.subject.tenantId')
8787
expect(paths).toContain('metadata.subject.subjectId')
88-
expect(paths).toContain('metadata.userEmail')
88+
expect(paths).not.toContain('metadata.userEmail')
8989
expect(paths).toContain('metadata.executionType')
9090
expect(paths).toContain('metadata.workflowId')
91-
expect(
92-
getEffectiveBlockOutputType('start_trigger', 'metadata.userEmail', subBlocks, options)
93-
).toBe('string')
9491
expect(
9592
getEffectiveBlockOutputType('start_trigger', 'metadata.subject.kind', subBlocks, options)
9693
).toBe('string')

apps/sim/lib/workflows/blocks/block-outputs.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,6 @@ const START_RUN_METADATA_OUTPUT = {
170170
subjectId: { type: 'string', description: 'Provider user ID for an external_user subject' },
171171
},
172172
},
173-
userEmail: {
174-
type: 'string',
175-
description: 'Email of the authenticated subject, or null when the subject has no email',
176-
},
177173
workspaceId: {
178174
type: 'string',
179175
description: 'Workspace ID of the invoking run (for custom blocks, the invoking workspace)',

apps/sim/lib/workflows/executor/start-run-identity.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ describe('resolveStartBlockRunIdentity', () => {
3333
userId: 'user-1',
3434
email: 'owner@example.com',
3535
},
36-
userEmail: 'owner@example.com',
3736
})
3837
expect(mockGetUserEmailById).toHaveBeenCalledWith('user-1')
3938
})
@@ -49,7 +48,6 @@ describe('resolveStartBlockRunIdentity', () => {
4948
})
5049
).resolves.toEqual({
5150
subject: { kind: 'authenticated_email', email: 'person@example.com' },
52-
userEmail: 'person@example.com',
5351
})
5452
expect(mockGetUserEmailById).not.toHaveBeenCalled()
5553
})
@@ -77,7 +75,6 @@ describe('resolveStartBlockRunIdentity', () => {
7775
tenantId: 'team-1',
7876
subjectId: 'slack-user-1',
7977
},
80-
userEmail: null,
8178
})
8279
expect(mockGetUserEmailById).not.toHaveBeenCalled()
8380
})
@@ -89,7 +86,7 @@ describe('resolveStartBlockRunIdentity', () => {
8986
workspaceId: 'workspace-1',
9087
keyId: 'key-1',
9188
})
92-
).resolves.toEqual({ subject: null, userEmail: null })
89+
).resolves.toEqual({ subject: null })
9390
expect(mockGetUserEmailById).not.toHaveBeenCalled()
9491
})
9592

apps/sim/lib/workflows/executor/start-run-identity.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,23 @@ import type { StartBlockRunSubject } from '@/executor/types'
44

55
export interface StartBlockRunIdentity {
66
subject: StartBlockRunSubject | null
7-
userEmail: string | null
87
}
98

109
/** Projects the authenticated execution principal into workflow-visible identity metadata. */
1110
export async function resolveStartBlockRunIdentity(
1211
principal: WorkflowExecutionPrincipal
1312
): Promise<StartBlockRunIdentity> {
1413
const subject = resolvePrincipalSubject(principal)
15-
if (!subject) return { subject: null, userEmail: null }
14+
if (!subject) return { subject: null }
1615

1716
switch (subject.kind) {
1817
case 'sim_user': {
1918
const email = await getUserEmailById(subject.userId)
20-
return {
21-
subject: { ...subject, email },
22-
userEmail: email,
23-
}
19+
return { subject: { ...subject, email } }
2420
}
2521
case 'authenticated_email':
26-
return { subject: { ...subject }, userEmail: subject.email }
22+
return { subject: { ...subject } }
2723
case 'external_user':
28-
return { subject: { ...subject }, userEmail: null }
24+
return { subject: { ...subject } }
2925
}
3026
}

0 commit comments

Comments
 (0)