Skip to content

Commit 86b8f74

Browse files
committed
remove comments
1 parent 1232548 commit 86b8f74

File tree

2 files changed

+2
-22
lines changed

2 files changed

+2
-22
lines changed

apps/sim/app/api/webhooks/[id]/route.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,7 @@ export async function PATCH(request: NextRequest, { params }: { params: Promise<
113113
}
114114
}
115115

116-
// Keep original config with {{ENV_VAR}} patterns for saving to DB
117116
const originalProviderConfig = providerConfig
118-
119-
// Resolve for processing (subscription checks) but don't save resolved values
120117
let resolvedProviderConfig = providerConfig
121118
if (providerConfig) {
122119
const webhookDataForResolve = await db
@@ -234,22 +231,17 @@ export async function PATCH(request: NextRequest, { params }: { params: Promise<
234231
hasFailedCountUpdate: failedCount !== undefined,
235232
})
236233

237-
// Merge providerConfig to preserve credential-related fields and system-managed fields
238-
// Use original config (preserves {{ENV_VAR}} patterns) + system fields from existing/updated
239234
let finalProviderConfig = webhooks[0].webhook.providerConfig
240235
if (providerConfig !== undefined && originalProviderConfig) {
241236
const existingConfig = existingProviderConfig
242237
finalProviderConfig = {
243-
// Start with original config (preserves {{ENV_VAR}} patterns)
244238
...originalProviderConfig,
245-
// Preserve credential-related and system-managed fields from existing
246239
credentialId: existingConfig.credentialId,
247240
credentialSetId: existingConfig.credentialSetId,
248241
userId: existingConfig.userId,
249242
historyId: existingConfig.historyId,
250243
lastCheckedTimestamp: existingConfig.lastCheckedTimestamp,
251244
setupCompleted: existingConfig.setupCompleted,
252-
// Use updated externalId from subscription recreation, or existing
253245
externalId: nextProviderConfig.externalId ?? existingConfig.externalId,
254246
}
255247
}

apps/sim/app/api/webhooks/route.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)