Skip to content

Commit 35ac68f

Browse files
author
Vikhyath Mondreti
committed
fix(func var resolution): variable ref codepath triggered - lint fixed
1 parent 9c14f5f commit 35ac68f

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

apps/sim/app/api/function/execute/route.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,9 @@ function resolveCodeVariables(
4444
// Resolve tags with <tag_name> syntax (including nested paths like <block.response.data>)
4545
const tagMatches = resolvedCode.match(/<([a-zA-Z_][a-zA-Z0-9_.]*[a-zA-Z0-9_])>/g) || []
4646

47-
4847
for (const match of tagMatches) {
4948
const tagName = match.slice(1, -1).trim()
5049

51-
5250
// Handle nested paths like "getrecord.response.data" or "function1.response.result"
5351
// First try params, then blockData directly, then try with block name mapping
5452
let tagValue = getNestedValue(params, tagName) || getNestedValue(blockData, tagName) || ''
@@ -76,15 +74,15 @@ function resolveCodeVariables(
7674
const remainingPath = pathParts.slice(1).join('.')
7775
const fullPath = `${blockId}.${remainingPath}`
7876
tagValue = getNestedValue(blockData, fullPath) || ''
79-
8077
}
8178
}
8279

83-
84-
8580
// If the value is a stringified JSON, parse it back to object
86-
if (typeof tagValue === 'string' && tagValue.length > 100 &&
87-
(tagValue.startsWith('{') || tagValue.startsWith('['))) {
81+
if (
82+
typeof tagValue === 'string' &&
83+
tagValue.length > 100 &&
84+
(tagValue.startsWith('{') || tagValue.startsWith('['))
85+
) {
8886
try {
8987
tagValue = JSON.parse(tagValue)
9088
} catch (e) {
@@ -156,8 +154,13 @@ export async function POST(req: NextRequest) {
156154
logger.info(`[${requestId}] Original code:`, code.substring(0, 200))
157155
logger.info(`[${requestId}] Execution params keys:`, Object.keys(executionParams))
158156

159-
160-
const { resolvedCode, contextVariables } = resolveCodeVariables(code, executionParams, envVars, blockData, blockNameMapping)
157+
const { resolvedCode, contextVariables } = resolveCodeVariables(
158+
code,
159+
executionParams,
160+
envVars,
161+
blockData,
162+
blockNameMapping
163+
)
161164

162165
logger.info(`[${requestId}] Resolved code:`, resolvedCode.substring(0, 200))
163166
logger.info(`[${requestId}] Context variables keys:`, Object.keys(contextVariables))

apps/sim/executor/handlers/function/function-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class FunctionBlockHandler implements BlockHandler {
3232
blockData[blockId] = blockState.output
3333

3434
// Try to find the block name from the workflow
35-
const workflowBlock = context.workflow?.blocks?.find(b => b.id === blockId)
35+
const workflowBlock = context.workflow?.blocks?.find((b) => b.id === blockId)
3636
if (workflowBlock?.metadata?.name) {
3737
blockNameMapping[workflowBlock.metadata.name] = blockId
3838
}

0 commit comments

Comments
 (0)