@@ -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 - z A - Z _ ] [ a - z A - Z 0 - 9 _ . ] * [ a - z A - Z 0 - 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 ) )
0 commit comments