@@ -8,6 +8,7 @@ import { executeInIsolatedVM } from '@/lib/execution/isolated-vm'
88import { CodeLanguage , DEFAULT_CODE_LANGUAGE , isValidCodeLanguage } from '@/lib/execution/languages'
99import { escapeRegExp , normalizeName , REFERENCE } from '@/executor/constants'
1010import { type OutputSchema , resolveBlockReference } from '@/executor/utils/block-reference'
11+ import { formatLiteralForCode } from '@/executor/utils/code-formatting'
1112import {
1213 createEnvVarPattern ,
1314 createWorkflowVariablePattern ,
@@ -387,7 +388,12 @@ function resolveWorkflowVariables(
387388 if ( type === 'number' ) {
388389 variableValue = Number ( variableValue )
389390 } else if ( type === 'boolean' ) {
390- variableValue = variableValue === 'true' || variableValue === true
391+ if ( typeof variableValue === 'boolean' ) {
392+ // Already a boolean, keep as-is
393+ } else {
394+ const normalized = String ( variableValue ) . toLowerCase ( ) . trim ( )
395+ variableValue = normalized === 'true'
396+ }
391397 } else if ( type === 'json' && typeof variableValue === 'string' ) {
392398 try {
393399 variableValue = JSON . parse ( variableValue )
@@ -687,11 +693,7 @@ export async function POST(req: NextRequest) {
687693 prologue += `const environmentVariables = JSON.parse(${ JSON . stringify ( JSON . stringify ( envVars ) ) } );\n`
688694 prologueLineCount ++
689695 for ( const [ k , v ] of Object . entries ( contextVariables ) ) {
690- if ( v === undefined ) {
691- prologue += `const ${ k } = undefined;\n`
692- } else {
693- prologue += `const ${ k } = JSON.parse(${ JSON . stringify ( JSON . stringify ( v ) ) } );\n`
694- }
696+ prologue += `const ${ k } = ${ formatLiteralForCode ( v , 'javascript' ) } ;\n`
695697 prologueLineCount ++
696698 }
697699
@@ -762,11 +764,7 @@ export async function POST(req: NextRequest) {
762764 prologue += `environmentVariables = json.loads(${ JSON . stringify ( JSON . stringify ( envVars ) ) } )\n`
763765 prologueLineCount ++
764766 for ( const [ k , v ] of Object . entries ( contextVariables ) ) {
765- if ( v === undefined ) {
766- prologue += `${ k } = None\n`
767- } else {
768- prologue += `${ k } = json.loads(${ JSON . stringify ( JSON . stringify ( v ) ) } )\n`
769- }
767+ prologue += `${ k } = ${ formatLiteralForCode ( v , 'python' ) } \n`
770768 prologueLineCount ++
771769 }
772770 const wrapped = [
0 commit comments