Skip to content

Commit d43247c

Browse files
committed
resolver change to make all var references optional chaining
1 parent ec5bcc2 commit d43247c

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

apps/sim/executor/variables/resolvers/block.test.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,14 @@ describe('BlockResolver', () => {
126126
expect(resolver.resolve('<source.items.1.id>', ctx)).toBe(2)
127127
})
128128

129-
it.concurrent('should throw error for non-existent path', () => {
129+
it.concurrent('should return undefined for non-existent path', () => {
130130
const workflow = createTestWorkflow([{ id: 'source' }])
131131
const resolver = new BlockResolver(workflow)
132132
const ctx = createTestContext('current', {
133133
source: { existing: 'value' },
134134
})
135135

136-
expect(() => resolver.resolve('<source.nonexistent>', ctx)).toThrow(
137-
/No value found at path "nonexistent" in block "source"/
138-
)
136+
expect(resolver.resolve('<source.nonexistent>', ctx)).toBeUndefined()
139137
})
140138

141139
it.concurrent('should return undefined for non-existent block', () => {
@@ -971,19 +969,17 @@ describe('BlockResolver', () => {
971969
source: { value: undefined, other: 'exists' },
972970
})
973971

974-
expect(() => resolver.resolve('<source.value>', ctx)).toThrow()
972+
expect(resolver.resolve('<source.value>', ctx)).toBeUndefined()
975973
})
976974

977-
it.concurrent('should handle deeply nested path errors', () => {
975+
it.concurrent('should return undefined for deeply nested non-existent path', () => {
978976
const workflow = createTestWorkflow([{ id: 'source' }])
979977
const resolver = new BlockResolver(workflow)
980978
const ctx = createTestContext('current', {
981979
source: { level1: { level2: {} } },
982980
})
983981

984-
expect(() => resolver.resolve('<source.level1.level2.level3>', ctx)).toThrow(
985-
/No value found at path "level1.level2.level3"/
986-
)
982+
expect(resolver.resolve('<source.level1.level2.level3>', ctx)).toBeUndefined()
987983
})
988984
})
989985
})

apps/sim/executor/variables/resolvers/block.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,7 @@ export class BlockResolver implements Resolver {
108108
}
109109
}
110110

111-
// If still undefined, throw error with original path
112-
const availableKeys = output && typeof output === 'object' ? Object.keys(output) : []
113-
throw new Error(
114-
`No value found at path "${pathParts.join('.')}" in block "${blockName}". Available fields: ${availableKeys.join(', ')}`
115-
)
111+
return undefined
116112
}
117113

118114
private getBlockOutput(blockId: string, context: ResolutionContext): any {

apps/sim/triggers/lemlist/utils.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,24 @@ const coreOutputs = {
8585
type: 'string',
8686
description: 'Lemlist team identifier',
8787
},
88+
} as const
89+
90+
/**
91+
* Campaign-related fields - only present when activity is part of a campaign
92+
* These may be missing for first replies or activities outside campaign context
93+
*/
94+
const campaignOutputs = {
8895
leadId: {
8996
type: 'string',
90-
description: 'Lead identifier',
97+
description: 'Lead identifier (only present for campaign activities)',
9198
},
9299
campaignId: {
93100
type: 'string',
94-
description: 'Campaign identifier',
101+
description: 'Campaign identifier (only present for campaign activities)',
95102
},
96103
campaignName: {
97104
type: 'string',
98-
description: 'Campaign name',
105+
description: 'Campaign name (only present for campaign activities)',
99106
},
100107
} as const
101108

@@ -193,6 +200,7 @@ const emailContentOutputs = {
193200
export function buildEmailSentOutputs(): Record<string, TriggerOutput> {
194201
return {
195202
...coreOutputs,
203+
...campaignOutputs,
196204
...leadOutputs,
197205
...sequenceOutputs,
198206
...senderOutputs,
@@ -206,6 +214,7 @@ export function buildEmailSentOutputs(): Record<string, TriggerOutput> {
206214
export function buildEmailRepliedOutputs(): Record<string, TriggerOutput> {
207215
return {
208216
...coreOutputs,
217+
...campaignOutputs,
209218
...leadOutputs,
210219
...sequenceOutputs,
211220
...senderOutputs,
@@ -219,6 +228,7 @@ export function buildEmailRepliedOutputs(): Record<string, TriggerOutput> {
219228
export function buildEmailOpenedOutputs(): Record<string, TriggerOutput> {
220229
return {
221230
...coreOutputs,
231+
...campaignOutputs,
222232
...leadOutputs,
223233
...sequenceOutputs,
224234
...senderOutputs,
@@ -235,6 +245,7 @@ export function buildEmailOpenedOutputs(): Record<string, TriggerOutput> {
235245
export function buildEmailClickedOutputs(): Record<string, TriggerOutput> {
236246
return {
237247
...coreOutputs,
248+
...campaignOutputs,
238249
...leadOutputs,
239250
...sequenceOutputs,
240251
...senderOutputs,
@@ -255,6 +266,7 @@ export function buildEmailClickedOutputs(): Record<string, TriggerOutput> {
255266
export function buildEmailBouncedOutputs(): Record<string, TriggerOutput> {
256267
return {
257268
...coreOutputs,
269+
...campaignOutputs,
258270
...leadOutputs,
259271
...sequenceOutputs,
260272
...senderOutputs,
@@ -275,6 +287,7 @@ export function buildEmailBouncedOutputs(): Record<string, TriggerOutput> {
275287
export function buildLinkedInRepliedOutputs(): Record<string, TriggerOutput> {
276288
return {
277289
...coreOutputs,
290+
...campaignOutputs,
278291
...leadOutputs,
279292
...sequenceOutputs,
280293
text: {
@@ -290,6 +303,7 @@ export function buildLinkedInRepliedOutputs(): Record<string, TriggerOutput> {
290303
export function buildInterestOutputs(): Record<string, TriggerOutput> {
291304
return {
292305
...coreOutputs,
306+
...campaignOutputs,
293307
...leadOutputs,
294308
...sequenceOutputs,
295309
} as Record<string, TriggerOutput>
@@ -302,6 +316,7 @@ export function buildInterestOutputs(): Record<string, TriggerOutput> {
302316
export function buildLemlistOutputs(): Record<string, TriggerOutput> {
303317
return {
304318
...coreOutputs,
319+
...campaignOutputs,
305320
...leadOutputs,
306321
...sequenceOutputs,
307322
...senderOutputs,

0 commit comments

Comments
 (0)