Skip to content

Commit c7ae3ef

Browse files
committed
fix(trigger): skip canonical-paired members when validating required fields on deploy
1 parent fb5ebd3 commit c7ae3ef

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

apps/sim/lib/webhooks/deploy.ts

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
} from '@/lib/webhooks/provider-subscriptions'
1414
import { getProviderHandler } from '@/lib/webhooks/providers'
1515
import { syncWebhooksForCredentialSet } from '@/lib/webhooks/utils.server'
16+
import { buildCanonicalIndex } from '@/lib/workflows/subblocks/visibility'
1617
import { getBlock } from '@/blocks'
1718
import type { SubBlockConfig } from '@/blocks/types'
1819
import type { BlockState } from '@/stores/workflows/workflow/types'
@@ -182,20 +183,32 @@ function buildProviderConfig(
182183
Object.entries(block.subBlocks || {}).map(([key, value]) => [key, { value: value.value }])
183184
)
184185

185-
triggerDef.subBlocks
186-
.filter(
187-
(subBlock) =>
188-
(subBlock.mode === 'trigger' || subBlock.mode === 'trigger-advanced') &&
189-
!SYSTEM_SUBBLOCK_IDS.includes(subBlock.id)
190-
)
191-
.forEach((subBlock) => {
192-
const valueToUse = getConfigValue(block, subBlock)
193-
if (valueToUse !== null && valueToUse !== undefined && valueToUse !== '') {
194-
providerConfig[subBlock.id] = valueToUse
195-
} else if (isFieldRequired(subBlock, subBlockValues)) {
196-
missingFields.push(subBlock.title || subBlock.id)
197-
}
198-
})
186+
const canonicalIndex = buildCanonicalIndex(triggerDef.subBlocks)
187+
const satisfiedCanonicalIds = new Set<string>()
188+
189+
const relevantSubBlocks = triggerDef.subBlocks.filter(
190+
(subBlock) =>
191+
(subBlock.mode === 'trigger' || subBlock.mode === 'trigger-advanced') &&
192+
!SYSTEM_SUBBLOCK_IDS.includes(subBlock.id)
193+
)
194+
195+
for (const subBlock of relevantSubBlocks) {
196+
const valueToUse = getConfigValue(block, subBlock)
197+
if (valueToUse !== null && valueToUse !== undefined && valueToUse !== '') {
198+
providerConfig[subBlock.id] = valueToUse
199+
const canonicalId = canonicalIndex.canonicalIdBySubBlockId[subBlock.id]
200+
if (canonicalId) satisfiedCanonicalIds.add(canonicalId)
201+
}
202+
}
203+
204+
for (const subBlock of relevantSubBlocks) {
205+
if (providerConfig[subBlock.id] !== undefined) continue
206+
const canonicalId = canonicalIndex.canonicalIdBySubBlockId[subBlock.id]
207+
if (canonicalId && satisfiedCanonicalIds.has(canonicalId)) continue
208+
if (isFieldRequired(subBlock, subBlockValues)) {
209+
missingFields.push(subBlock.title || subBlock.id)
210+
}
211+
}
199212

200213
const credentialConfig = triggerDef.subBlocks.find(
201214
(subBlock) => subBlock.id === 'triggerCredentials'

0 commit comments

Comments
 (0)