Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 29 additions & 14 deletions apps/sim/lib/webhooks/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from '@/lib/webhooks/provider-subscriptions'
import { getProviderHandler } from '@/lib/webhooks/providers'
import { syncWebhooksForCredentialSet } from '@/lib/webhooks/utils.server'
import { buildCanonicalIndex } from '@/lib/workflows/subblocks/visibility'
import { getBlock } from '@/blocks'
import type { SubBlockConfig } from '@/blocks/types'
import type { BlockState } from '@/stores/workflows/workflow/types'
Expand Down Expand Up @@ -182,20 +183,34 @@ function buildProviderConfig(
Object.entries(block.subBlocks || {}).map(([key, value]) => [key, { value: value.value }])
)

triggerDef.subBlocks
.filter(
(subBlock) =>
(subBlock.mode === 'trigger' || subBlock.mode === 'trigger-advanced') &&
!SYSTEM_SUBBLOCK_IDS.includes(subBlock.id)
)
.forEach((subBlock) => {
const valueToUse = getConfigValue(block, subBlock)
if (valueToUse !== null && valueToUse !== undefined && valueToUse !== '') {
providerConfig[subBlock.id] = valueToUse
} else if (isFieldRequired(subBlock, subBlockValues)) {
missingFields.push(subBlock.title || subBlock.id)
}
})
const canonicalIndex = buildCanonicalIndex(triggerDef.subBlocks)
const satisfiedCanonicalIds = new Set<string>()
const filledSubBlockIds = new Set<string>()

const relevantSubBlocks = triggerDef.subBlocks.filter(
(subBlock) =>
(subBlock.mode === 'trigger' || subBlock.mode === 'trigger-advanced') &&
!SYSTEM_SUBBLOCK_IDS.includes(subBlock.id)
)

for (const subBlock of relevantSubBlocks) {
const valueToUse = getConfigValue(block, subBlock)
if (valueToUse !== null && valueToUse !== undefined && valueToUse !== '') {
providerConfig[subBlock.id] = valueToUse
filledSubBlockIds.add(subBlock.id)
const canonicalId = canonicalIndex.canonicalIdBySubBlockId[subBlock.id]
if (canonicalId) satisfiedCanonicalIds.add(canonicalId)
}
}

for (const subBlock of relevantSubBlocks) {
if (filledSubBlockIds.has(subBlock.id)) continue
const canonicalId = canonicalIndex.canonicalIdBySubBlockId[subBlock.id]
if (canonicalId && satisfiedCanonicalIds.has(canonicalId)) continue
if (isFieldRequired(subBlock, subBlockValues)) {
missingFields.push(subBlock.title || subBlock.id)
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale baseConfig values bypass required field validation

Medium Severity

The second-pass guard providerConfig[subBlock.id] !== undefined can be satisfied by stale values inherited from baseConfig (spread into providerConfig at initialization), not just values set during the first pass. If triggerConfig contains a leftover entry for a field the user has since cleared, the required-field check is silently skipped, allowing deployment with missing required fields. The old code always validated against getConfigValue results regardless of providerConfig contents. A separate Set tracking first-pass fills would be more reliable than checking providerConfig.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c7ae3ef. Configure here.


const credentialConfig = triggerDef.subBlocks.find(
(subBlock) => subBlock.id === 'triggerCredentials'
Expand Down
Loading