fix(func var resolution): variable ref codepath triggered - lint fixed

This commit is contained in:
Vikhyath Mondreti
2025-06-30 13:55:12 -07:00
parent 9c14f5f8fc
commit 35ac68f579
2 changed files with 13 additions and 10 deletions

View File

@@ -44,11 +44,9 @@ function resolveCodeVariables(
// Resolve tags with <tag_name> syntax (including nested paths like <block.response.data>)
const tagMatches = resolvedCode.match(/<([a-zA-Z_][a-zA-Z0-9_.]*[a-zA-Z0-9_])>/g) || []
for (const match of tagMatches) {
const tagName = match.slice(1, -1).trim()
// Handle nested paths like "getrecord.response.data" or "function1.response.result"
// First try params, then blockData directly, then try with block name mapping
let tagValue = getNestedValue(params, tagName) || getNestedValue(blockData, tagName) || ''
@@ -76,15 +74,15 @@ function resolveCodeVariables(
const remainingPath = pathParts.slice(1).join('.')
const fullPath = `${blockId}.${remainingPath}`
tagValue = getNestedValue(blockData, fullPath) || ''
}
}
// If the value is a stringified JSON, parse it back to object
if (typeof tagValue === 'string' && tagValue.length > 100 &&
(tagValue.startsWith('{') || tagValue.startsWith('['))) {
if (
typeof tagValue === 'string' &&
tagValue.length > 100 &&
(tagValue.startsWith('{') || tagValue.startsWith('['))
) {
try {
tagValue = JSON.parse(tagValue)
} catch (e) {
@@ -156,8 +154,13 @@ export async function POST(req: NextRequest) {
logger.info(`[${requestId}] Original code:`, code.substring(0, 200))
logger.info(`[${requestId}] Execution params keys:`, Object.keys(executionParams))
const { resolvedCode, contextVariables } = resolveCodeVariables(code, executionParams, envVars, blockData, blockNameMapping)
const { resolvedCode, contextVariables } = resolveCodeVariables(
code,
executionParams,
envVars,
blockData,
blockNameMapping
)
logger.info(`[${requestId}] Resolved code:`, resolvedCode.substring(0, 200))
logger.info(`[${requestId}] Context variables keys:`, Object.keys(contextVariables))