Skip to content

Commit 2d2e86c

Browse files
committed
update change detection to ignore trigger id since it is runtime metadata and not actually required to be redeployed
1 parent b71ac33 commit 2d2e86c

File tree

2 files changed

+246
-2
lines changed

2 files changed

+246
-2
lines changed

apps/sim/lib/workflows/comparison/compare.test.ts

Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2267,4 +2267,245 @@ describe('hasWorkflowChanged', () => {
22672267
expect(hasWorkflowChanged(currentState as any, deployedState as any)).toBe(false)
22682268
})
22692269
})
2270+
2271+
describe('Trigger Runtime Metadata (Should Not Trigger Change)', () => {
2272+
it.concurrent('should not detect change when webhookId differs', () => {
2273+
const deployedState = createWorkflowState({
2274+
blocks: {
2275+
block1: createBlock('block1', {
2276+
type: 'starter',
2277+
subBlocks: {
2278+
triggerConfig: { value: { event: 'push' } },
2279+
webhookId: { value: null },
2280+
},
2281+
}),
2282+
},
2283+
})
2284+
2285+
const currentState = createWorkflowState({
2286+
blocks: {
2287+
block1: createBlock('block1', {
2288+
type: 'starter',
2289+
subBlocks: {
2290+
triggerConfig: { value: { event: 'push' } },
2291+
webhookId: { value: 'wh_123456' },
2292+
},
2293+
}),
2294+
},
2295+
})
2296+
2297+
expect(hasWorkflowChanged(currentState, deployedState)).toBe(false)
2298+
})
2299+
2300+
it.concurrent('should not detect change when triggerPath differs', () => {
2301+
const deployedState = createWorkflowState({
2302+
blocks: {
2303+
block1: createBlock('block1', {
2304+
type: 'starter',
2305+
subBlocks: {
2306+
triggerConfig: { value: { event: 'push' } },
2307+
triggerPath: { value: '' },
2308+
},
2309+
}),
2310+
},
2311+
})
2312+
2313+
const currentState = createWorkflowState({
2314+
blocks: {
2315+
block1: createBlock('block1', {
2316+
type: 'starter',
2317+
subBlocks: {
2318+
triggerConfig: { value: { event: 'push' } },
2319+
triggerPath: { value: '/api/webhooks/abc123' },
2320+
},
2321+
}),
2322+
},
2323+
})
2324+
2325+
expect(hasWorkflowChanged(currentState, deployedState)).toBe(false)
2326+
})
2327+
2328+
it.concurrent('should not detect change when testUrl differs', () => {
2329+
const deployedState = createWorkflowState({
2330+
blocks: {
2331+
block1: createBlock('block1', {
2332+
type: 'starter',
2333+
subBlocks: {
2334+
triggerConfig: { value: { event: 'push' } },
2335+
testUrl: { value: null },
2336+
},
2337+
}),
2338+
},
2339+
})
2340+
2341+
const currentState = createWorkflowState({
2342+
blocks: {
2343+
block1: createBlock('block1', {
2344+
type: 'starter',
2345+
subBlocks: {
2346+
triggerConfig: { value: { event: 'push' } },
2347+
testUrl: { value: 'https://test.example.com/webhook' },
2348+
},
2349+
}),
2350+
},
2351+
})
2352+
2353+
expect(hasWorkflowChanged(currentState, deployedState)).toBe(false)
2354+
})
2355+
2356+
it.concurrent('should not detect change when testUrlExpiresAt differs', () => {
2357+
const deployedState = createWorkflowState({
2358+
blocks: {
2359+
block1: createBlock('block1', {
2360+
type: 'starter',
2361+
subBlocks: {
2362+
triggerConfig: { value: { event: 'push' } },
2363+
testUrlExpiresAt: { value: null },
2364+
},
2365+
}),
2366+
},
2367+
})
2368+
2369+
const currentState = createWorkflowState({
2370+
blocks: {
2371+
block1: createBlock('block1', {
2372+
type: 'starter',
2373+
subBlocks: {
2374+
triggerConfig: { value: { event: 'push' } },
2375+
testUrlExpiresAt: { value: '2025-12-31T23:59:59Z' },
2376+
},
2377+
}),
2378+
},
2379+
})
2380+
2381+
expect(hasWorkflowChanged(currentState, deployedState)).toBe(false)
2382+
})
2383+
2384+
it.concurrent('should not detect change when all runtime metadata differs', () => {
2385+
const deployedState = createWorkflowState({
2386+
blocks: {
2387+
block1: createBlock('block1', {
2388+
type: 'starter',
2389+
subBlocks: {
2390+
triggerConfig: { value: { event: 'push' } },
2391+
webhookId: { value: null },
2392+
triggerPath: { value: '' },
2393+
testUrl: { value: null },
2394+
testUrlExpiresAt: { value: null },
2395+
},
2396+
}),
2397+
},
2398+
})
2399+
2400+
const currentState = createWorkflowState({
2401+
blocks: {
2402+
block1: createBlock('block1', {
2403+
type: 'starter',
2404+
subBlocks: {
2405+
triggerConfig: { value: { event: 'push' } },
2406+
webhookId: { value: 'wh_123456' },
2407+
triggerPath: { value: '/api/webhooks/abc123' },
2408+
testUrl: { value: 'https://test.example.com/webhook' },
2409+
testUrlExpiresAt: { value: '2025-12-31T23:59:59Z' },
2410+
},
2411+
}),
2412+
},
2413+
})
2414+
2415+
expect(hasWorkflowChanged(currentState, deployedState)).toBe(false)
2416+
})
2417+
2418+
it.concurrent(
2419+
'should detect change when triggerConfig differs but runtime metadata also differs',
2420+
() => {
2421+
const deployedState = createWorkflowState({
2422+
blocks: {
2423+
block1: createBlock('block1', {
2424+
type: 'starter',
2425+
subBlocks: {
2426+
triggerConfig: { value: { event: 'push' } },
2427+
webhookId: { value: null },
2428+
},
2429+
}),
2430+
},
2431+
})
2432+
2433+
const currentState = createWorkflowState({
2434+
blocks: {
2435+
block1: createBlock('block1', {
2436+
type: 'starter',
2437+
subBlocks: {
2438+
triggerConfig: { value: { event: 'pull_request' } },
2439+
webhookId: { value: 'wh_123456' },
2440+
},
2441+
}),
2442+
},
2443+
})
2444+
2445+
expect(hasWorkflowChanged(currentState, deployedState)).toBe(true)
2446+
}
2447+
)
2448+
2449+
it.concurrent(
2450+
'should not detect change when runtime metadata is added to current state',
2451+
() => {
2452+
const deployedState = createWorkflowState({
2453+
blocks: {
2454+
block1: createBlock('block1', {
2455+
type: 'starter',
2456+
subBlocks: {
2457+
triggerConfig: { value: { event: 'push' } },
2458+
},
2459+
}),
2460+
},
2461+
})
2462+
2463+
const currentState = createWorkflowState({
2464+
blocks: {
2465+
block1: createBlock('block1', {
2466+
type: 'starter',
2467+
subBlocks: {
2468+
triggerConfig: { value: { event: 'push' } },
2469+
webhookId: { value: 'wh_123456' },
2470+
triggerPath: { value: '/api/webhooks/abc123' },
2471+
},
2472+
}),
2473+
},
2474+
})
2475+
2476+
expect(hasWorkflowChanged(currentState, deployedState)).toBe(false)
2477+
}
2478+
)
2479+
2480+
it.concurrent(
2481+
'should not detect change when runtime metadata is removed from current state',
2482+
() => {
2483+
const deployedState = createWorkflowState({
2484+
blocks: {
2485+
block1: createBlock('block1', {
2486+
type: 'starter',
2487+
subBlocks: {
2488+
triggerConfig: { value: { event: 'push' } },
2489+
webhookId: { value: 'wh_old123' },
2490+
triggerPath: { value: '/api/webhooks/old' },
2491+
},
2492+
}),
2493+
},
2494+
})
2495+
2496+
const currentState = createWorkflowState({
2497+
blocks: {
2498+
block1: createBlock('block1', {
2499+
type: 'starter',
2500+
subBlocks: {
2501+
triggerConfig: { value: { event: 'push' } },
2502+
},
2503+
}),
2504+
},
2505+
})
2506+
2507+
expect(hasWorkflowChanged(currentState, deployedState)).toBe(false)
2508+
}
2509+
)
2510+
})
22702511
})

apps/sim/lib/workflows/comparison/compare.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { WorkflowState } from '@/stores/workflows/workflow/types'
2+
import { TRIGGER_RUNTIME_SUBBLOCK_IDS } from '@/triggers/constants'
23
import {
34
normalizedStringify,
45
normalizeEdge,
@@ -100,10 +101,12 @@ export function hasWorkflowChanged(
100101
subBlocks: undefined,
101102
}
102103

103-
// Get all subBlock IDs from both states
104+
// Get all subBlock IDs from both states, excluding runtime metadata
104105
const allSubBlockIds = [
105106
...new Set([...Object.keys(currentSubBlocks), ...Object.keys(deployedSubBlocks)]),
106-
].sort()
107+
]
108+
.filter((id) => !TRIGGER_RUNTIME_SUBBLOCK_IDS.includes(id))
109+
.sort()
107110

108111
// Normalize and compare each subBlock
109112
for (const subBlockId of allSubBlockIds) {

0 commit comments

Comments
 (0)