@@ -299,14 +299,8 @@ export async function POST(request: NextRequest) {
299299 }
300300 }
301301
302- let savedWebhook : any = null // Variable to hold the result of save/update
303-
304- // Keep original config with {{ENV_VAR}} patterns - these should be saved to DB
305- // and resolved at runtime, so users can update env vars without recreating webhooks
302+ let savedWebhook : any = null
306303 const originalProviderConfig = providerConfig || { }
307-
308- // Resolve env vars for processing (credential detection, external subscriptions)
309- // but don't save resolved values - save original patterns instead
310304 let resolvedProviderConfig = await resolveEnvVarsInObject (
311305 originalProviderConfig ,
312306 userId ,
@@ -472,7 +466,6 @@ export async function POST(request: NextRequest) {
472466 providerConfig : providerConfigOverride ,
473467 } )
474468
475- // Config to save to DB - starts with original (preserves {{ENV_VAR}} patterns)
476469 const configToSave = { ...originalProviderConfig }
477470
478471 try {
@@ -483,16 +476,13 @@ export async function POST(request: NextRequest) {
483476 userId ,
484477 requestId
485478 )
486- // Merge any new fields (like externalId) from external subscription into original config
487- // This preserves {{ENV_VAR}} patterns while adding system-managed fields
488479 const updatedConfig = result . updatedProviderConfig as Record < string , unknown >
489480 for ( const [ key , value ] of Object . entries ( updatedConfig ) ) {
490481 if ( ! ( key in originalProviderConfig ) ) {
491- // New field added by external subscription (e.g., externalId, subscriptionId)
492482 configToSave [ key ] = value
493483 }
494484 }
495- resolvedProviderConfig = updatedConfig // Keep for logging/credential checks
485+ resolvedProviderConfig = updatedConfig
496486 externalSubscriptionCreated = result . externalSubscriptionCreated
497487 } catch ( err ) {
498488 logger . error ( `[${ requestId } ] Error creating external webhook subscription` , err )
@@ -505,8 +495,6 @@ export async function POST(request: NextRequest) {
505495 )
506496 }
507497
508- // Now save to database (only if subscription succeeded or provider doesn't need external subscription)
509- // Save configToSave which preserves {{ENV_VAR}} patterns + system-managed fields
510498 try {
511499 if ( targetWebhookId ) {
512500 logger . info ( `[${ requestId } ] Updating existing webhook for path: ${ finalPath } ` , {
0 commit comments