Skip to content

Commit f6a4b8e

Browse files
committed
address bugbot
1 parent 86b8f74 commit f6a4b8e

File tree

3 files changed

+11
-24
lines changed

3 files changed

+11
-24
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,11 @@ export async function PATCH(request: NextRequest, { params }: { params: Promise<
242242
historyId: existingConfig.historyId,
243243
lastCheckedTimestamp: existingConfig.lastCheckedTimestamp,
244244
setupCompleted: existingConfig.setupCompleted,
245-
externalId: nextProviderConfig.externalId ?? existingConfig.externalId,
245+
}
246+
for (const [key, value] of Object.entries(nextProviderConfig)) {
247+
if (!(key in originalProviderConfig)) {
248+
;(finalProviderConfig as Record<string, unknown>)[key] = value
249+
}
246250
}
247251
}
248252

apps/sim/lib/mcp/shared.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,3 @@ export function createMcpToolId(serverId: string, toolName: string): string {
4646
const normalizedServerId = isMcpTool(serverId) ? serverId : `${MCP.TOOL_PREFIX}${serverId}`
4747
return `${normalizedServerId}-${toolName}`
4848
}
49-
50-
/**
51-
* Parse an MCP tool ID back into server ID and tool name
52-
*/
53-
export function parseMcpToolId(toolId: string): { serverId: string; toolName: string } {
54-
// Remove the MCP tool prefix if present to get the base ID
55-
const baseId = toolId.startsWith(MCP.TOOL_PREFIX) ? toolId.slice(MCP.TOOL_PREFIX.length) : toolId
56-
57-
// Find the last hyphen to split server ID and tool name
58-
const lastHyphenIndex = baseId.lastIndexOf('-')
59-
if (lastHyphenIndex === -1) {
60-
return { serverId: baseId, toolName: '' }
61-
}
62-
63-
const serverId = baseId.slice(0, lastHyphenIndex)
64-
const toolName = baseId.slice(lastHyphenIndex + 1)
65-
66-
return { serverId, toolName }
67-
}

apps/sim/lib/webhooks/env-resolver.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@ import { resolveEnvVarReferences } from '@/executor/utils/reference-validation'
55
* Recursively resolves all environment variable references in a configuration object.
66
* Supports both exact matches (`{{VAR_NAME}}`) and embedded patterns (`https://{{HOST}}/path`).
77
*
8+
* Uses `deep: true` because webhook configs have nested structures that need full resolution.
9+
*
810
* @param config - Configuration object that may contain env var references
911
* @param userId - User ID to fetch environment variables for
1012
* @param workspaceId - Optional workspace ID for workspace-specific env vars
1113
* @returns A new object with all env var references resolved
1214
*/
13-
export async function resolveEnvVarsInObject(
14-
config: Record<string, any>,
15+
export async function resolveEnvVarsInObject<T extends Record<string, unknown>>(
16+
config: T,
1517
userId: string,
1618
workspaceId?: string
17-
): Promise<Record<string, any>> {
19+
): Promise<T> {
1820
const envVars = await getEffectiveDecryptedEnv(userId, workspaceId)
19-
return resolveEnvVarReferences(config, envVars, { deep: true }) as Record<string, any>
21+
return resolveEnvVarReferences(config, envVars, { deep: true }) as T
2022
}

0 commit comments

Comments
 (0)