@@ -32,6 +32,12 @@ interface TriggerSaveError {
3232interface TriggerSaveResult {
3333 success : boolean
3434 error ?: TriggerSaveError
35+ warnings ?: string [ ]
36+ }
37+
38+ interface CredentialSetSyncResult {
39+ error : TriggerSaveError | null
40+ warnings : string [ ]
3541}
3642
3743interface SaveTriggerWebhooksInput {
@@ -258,7 +264,7 @@ async function syncCredentialSetWebhooks(params: {
258264 providerConfig : Record < string , unknown >
259265 requestId : string
260266 deploymentVersionId ?: string
261- } ) : Promise < TriggerSaveError | null > {
267+ } ) : Promise < CredentialSetSyncResult > {
262268 const {
263269 workflowId,
264270 blockId,
@@ -271,7 +277,7 @@ async function syncCredentialSetWebhooks(params: {
271277
272278 const credentialSetId = providerConfig . credentialSetId as string | undefined
273279 if ( ! credentialSetId ) {
274- return null
280+ return { error : null , warnings : [ ] }
275281 }
276282
277283 const oauthProviderId = getProviderIdFromServiceId ( provider )
@@ -290,10 +296,23 @@ async function syncCredentialSetWebhooks(params: {
290296 deploymentVersionId,
291297 } )
292298
299+ const warnings : string [ ] = [ ]
300+
301+ if ( syncResult . failed . length > 0 ) {
302+ const failedCount = syncResult . failed . length
303+ const totalCount = syncResult . webhooks . length + failedCount
304+ warnings . push (
305+ `${ failedCount } of ${ totalCount } credentials in the set failed to sync for ${ provider } . Some team members may not receive triggers.`
306+ )
307+ }
308+
293309 if ( syncResult . webhooks . length === 0 ) {
294310 return {
295- message : `No valid credentials found in credential set for ${ provider } . Please connect accounts and try again.` ,
296- status : 400 ,
311+ error : {
312+ message : `No valid credentials found in credential set for ${ provider } . Please connect accounts and try again.` ,
313+ status : 400 ,
314+ } ,
315+ warnings,
297316 }
298317 }
299318
@@ -307,16 +326,19 @@ async function syncCredentialSetWebhooks(params: {
307326 if ( ! success ) {
308327 await db . delete ( webhook ) . where ( eq ( webhook . id , wh . id ) )
309328 return {
310- message : `Failed to configure ${ provider } polling. Please check account permissions.` ,
311- status : 500 ,
329+ error : {
330+ message : `Failed to configure ${ provider } polling. Please check account permissions.` ,
331+ status : 500 ,
332+ } ,
333+ warnings,
312334 }
313335 }
314336 }
315337 }
316338 }
317339 }
318340
319- return null
341+ return { error : null , warnings }
320342}
321343
322344/**
@@ -503,14 +525,16 @@ export async function saveTriggerWebhooksForDeploy({
503525 await db . delete ( webhook ) . where ( inArray ( webhook . id , idsToDelete ) )
504526 }
505527
528+ const collectedWarnings : string [ ] = [ ]
529+
506530 for ( const block of blocksNeedingCredentialSetSync ) {
507531 const config = webhookConfigs . get ( block . id )
508532 if ( ! config ) continue
509533
510534 const { provider, providerConfig, triggerPath } = config
511535
512536 try {
513- const credentialSetError = await syncCredentialSetWebhooks ( {
537+ const syncResult = await syncCredentialSetWebhooks ( {
514538 workflowId,
515539 blockId : block . id ,
516540 provider,
@@ -520,9 +544,13 @@ export async function saveTriggerWebhooksForDeploy({
520544 deploymentVersionId,
521545 } )
522546
523- if ( credentialSetError ) {
547+ if ( syncResult . warnings . length > 0 ) {
548+ collectedWarnings . push ( ...syncResult . warnings )
549+ }
550+
551+ if ( syncResult . error ) {
524552 await restorePreviousSubscriptions ( )
525- return { success : false , error : credentialSetError }
553+ return { success : false , error : syncResult . error , warnings : collectedWarnings }
526554 }
527555 } catch ( error : any ) {
528556 logger . error ( `[${ requestId } ] Failed to create webhook for ${ block . id } ` , error )
@@ -533,6 +561,7 @@ export async function saveTriggerWebhooksForDeploy({
533561 message : error ?. message || 'Failed to save trigger configuration' ,
534562 status : 500 ,
535563 } ,
564+ warnings : collectedWarnings ,
536565 }
537566 }
538567 }
@@ -708,7 +737,7 @@ export async function saveTriggerWebhooksForDeploy({
708737 }
709738 }
710739
711- return { success : true }
740+ return { success : true , warnings : collectedWarnings . length > 0 ? collectedWarnings : undefined }
712741}
713742
714743/**
0 commit comments