@@ -101,23 +101,35 @@ class Choice extends Processor {
101101 // Apply the choice result
102102 if ( conditionResult ) {
103103 if ( trueProperty && trueValue !== undefined ) {
104- // Try to get value from message path, fallback to literal value
104+ // Try to get value from message path
105105 let actualTrueValue = JSONUtils . get ( message , trueValue )
106- if ( actualTrueValue === undefined ) {
107- actualTrueValue = trueValue
106+ // Only set if value exists, or if it's a simple literal (no dots/brackets)
107+ if ( actualTrueValue !== undefined ) {
108+ JSONUtils . set ( message , trueProperty , actualTrueValue )
109+ logger . debug ( `Choice: TRUE - Set ${ trueProperty } ="${ actualTrueValue } "` )
110+ } else if ( ! trueValue . includes ( '.' ) && ! trueValue . includes ( '[' ) ) {
111+ // Simple literal value (not a path)
112+ JSONUtils . set ( message , trueProperty , trueValue )
113+ logger . debug ( `Choice: TRUE - Set ${ trueProperty } ="${ trueValue } "` )
114+ } else {
115+ logger . debug ( `Choice: TRUE - Skipping set, ${ trueValue } not found in message` )
108116 }
109- JSONUtils . set ( message , trueProperty , actualTrueValue )
110- logger . debug ( `Choice: TRUE - Set ${ trueProperty } ="${ actualTrueValue } "` )
111117 }
112118 } else {
113119 if ( falseProperty && falseValue !== undefined ) {
114- // Try to get value from message path, fallback to literal value
120+ // Try to get value from message path
115121 let actualFalseValue = JSONUtils . get ( message , falseValue )
116- if ( actualFalseValue === undefined ) {
117- actualFalseValue = falseValue
122+ // Only set if value exists, or if it's a simple literal (no dots/brackets)
123+ if ( actualFalseValue !== undefined ) {
124+ JSONUtils . set ( message , falseProperty , actualFalseValue )
125+ logger . debug ( `Choice: FALSE - Set ${ falseProperty } ="${ actualFalseValue } "` )
126+ } else if ( ! falseValue . includes ( '.' ) && ! falseValue . includes ( '[' ) ) {
127+ // Simple literal value (not a path)
128+ JSONUtils . set ( message , falseProperty , falseValue )
129+ logger . debug ( `Choice: FALSE - Set ${ falseProperty } ="${ falseValue } "` )
130+ } else {
131+ logger . debug ( `Choice: FALSE - Skipping set, ${ falseValue } not found in message` )
118132 }
119- JSONUtils . set ( message , falseProperty , actualFalseValue )
120- logger . debug ( `Choice: FALSE - Set ${ falseProperty } ="${ actualFalseValue } "` )
121133 }
122134 }
123135
0 commit comments