Skip to content

Commit 14013aa

Browse files
fix(workflows): remove duplicate run email metadata
1 parent c9585a8 commit 14013aa

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
@@ -879,7 +879,6 @@ describe('WorkflowBlockHandler', () => {
879879
userId: 'consumer-1',
880880
email: 'a@corp.com',
881881
},
882-
userEmail: 'a@corp.com',
883882
workspaceId: 'workspace-consumer',
884883
workflowId: 'parent-workflow-id',
885884
executionId: 'exec-1',
@@ -902,7 +901,6 @@ describe('WorkflowBlockHandler', () => {
902901
userId: 'original-user',
903902
email: 'original@corp.com',
904903
},
905-
userEmail: 'original@corp.com',
906904
workspaceId: 'workspace-original',
907905
workflowId: 'workflow-original',
908906
executionId: 'exec-1',
@@ -987,7 +985,6 @@ describe('WorkflowBlockHandler', () => {
987985
userId: 'original-user',
988986
email: 'original@corp.com',
989987
},
990-
userEmail: 'original@corp.com',
991988
workspaceId: 'workspace-original',
992989
workflowId: 'workflow-original',
993990
executionMode: 'async',
@@ -1002,7 +999,6 @@ describe('WorkflowBlockHandler', () => {
1002999
workspaceId: 'workspace-parent',
10031000
startRunMetadata: {
10041001
subject: null,
1005-
userEmail: null,
10061002
workspaceId: 'workspace-original',
10071003
workflowId: 'workflow-original',
10081004
},
@@ -1043,7 +1039,6 @@ describe('WorkflowBlockHandler', () => {
10431039

10441040
expect(executorOptions).toHaveLength(1)
10451041
expect(executorOptions[0].contextExtensions.startRunMetadata.subject).toBeNull()
1046-
expect(executorOptions[0].contextExtensions.startRunMetadata.userEmail).toBeNull()
10471042
expect(mockGetUserEmailById).not.toHaveBeenCalled()
10481043
})
10491044

@@ -1053,7 +1048,6 @@ describe('WorkflowBlockHandler', () => {
10531048
kind: 'authenticated_email' as const,
10541049
email: 'original@corp.com',
10551050
},
1056-
userEmail: 'original@corp.com',
10571051
workspaceId: 'workspace-original',
10581052
workflowId: 'workflow-original',
10591053
executionMode: 'sync',
@@ -1119,7 +1113,6 @@ describe('WorkflowBlockHandler', () => {
11191113
kind: 'authenticated_email',
11201114
email: 'original@corp.com',
11211115
},
1122-
userEmail: 'original@corp.com',
11231116
workspaceId: 'workspace-original',
11241117
workflowId: 'workflow-original',
11251118
})
@@ -1132,7 +1125,6 @@ describe('WorkflowBlockHandler', () => {
11321125
kind: 'authenticated_email' as const,
11331126
email: 'original@corp.com',
11341127
},
1135-
userEmail: 'original@corp.com',
11361128
workspaceId: 'workspace-original',
11371129
workflowId: 'workflow-original',
11381130
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,6 @@ export class WorkflowBlockHandler implements BlockHandler {
725725
if (inherited && Object.hasOwn(inherited, 'subject')) {
726726
invokingIdentity = {
727727
subject: inherited.subject ?? null,
728-
userEmail: inherited.userEmail ?? null,
729728
}
730729
} else {
731730
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
@@ -171,10 +171,6 @@ const START_RUN_METADATA_OUTPUT = {
171171
subjectId: { type: 'string', description: 'Provider user ID for an external_user subject' },
172172
},
173173
},
174-
userEmail: {
175-
type: 'string',
176-
description: 'Email of the authenticated subject, or null when the subject has no email',
177-
},
178174
workspaceId: {
179175
type: 'string',
180176
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)