{"record":{"id":"5a13fd6f3d0c1fd6","repo":"pentaho/pentaho-kettle","slug":"unexpected-error-evaluation-condition","errorCode":null,"errorMessage":"Unexpected error evaluation condition [","messagePattern":"Unexpected error evaluation condition \\[","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/Condition.java","lineNumber":561,"sourceCode":"              break;\n            case Condition.OPERATOR_AND_NOT:\n              retval = retval && ( !cb.evaluate( rowMeta, r ) );\n              break;\n            case Condition.OPERATOR_XOR:\n              retval = retval ^ cb.evaluate( rowMeta, r );\n              break;\n            default:\n              break;\n          }\n        }\n\n        // Composite: optionally negate\n        if ( isNegated() ) {\n          retval = !retval;\n        }\n      }\n    } catch ( Exception e ) {\n      throw new RuntimeException( \"Unexpected error evaluation condition [\" + toString() + \"]\", e );\n    }\n\n    return retval;\n  }\n\n  public void addCondition( Condition cb ) {\n    if ( isAtomic() && getLeftValuename() != null ) {\n      /*\n       * Copy current atomic setup...\n       */\n      Condition current = new Condition( getLeftValuename(), getFunction(), getRightValuename(), getRightExact() );\n      current.setNegated( isNegated() );\n      setNegated( false );\n      list.add( current );\n    } else {\n      // Set default operator if not on first position...\n      if ( isComposite() && !list.isEmpty() && cb.getOperator() == OPERATOR_NONE ) {\n        cb.setOperator( OPERATOR_AND );","sourceCodeStart":543,"sourceCodeEnd":579,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/Condition.java#L543-L579","documentation":"Condition.evaluate() wraps the whole condition evaluation (field comparisons, negation, composite sub-conditions) in a catch-all that rethrows any Exception as RuntimeException 'Unexpected error evaluation condition [<toString()>]'. It is a defensive wrapper: any failure comparing values, parsing data, or evaluating sub-conditions surfaces with the condition's textual representation for debugging.","triggerScenarios":"Evaluating a Condition whose field values are of incompatible types (e.g. comparing null against a number/string in a way the comparator cannot handle), or whose field data is missing/malformed at evaluation time; also triggered in composite conditions when a sub-condition's evaluate throws.","commonSituations":"Transformation row filters / job entry conditions where a field is unexpectedly null or of the wrong type at runtime; conditions copied between steps whose referenced fields no longer exist; historically reported bugs like PDI-13227 (null vs number comparison).","solutions":["Inspect the condition text in the message and check the operand types — ensure the compared fields exist and have compatible types at runtime","Guard against null values in the data (e.g. replace nulls with defaults before the filter step) or restructure the condition","Update to a PDI version with fixes for Condition null-comparison bugs (e.g. PDI-13227)"],"exampleFix":"// before\nFilter rows: field = [amount], condition = '<', value = 10 // amount is sometimes null -> RuntimeException\n// after\nAdd a 'Field exists / not null' check first, or use a coalesce step:\nif (row.getInteger(\"amount\") != null) { /* evaluate */ }","handlingStrategy":"try-catch","validationCode":"// Before adding/evaluating a condition, verify fields exist and values are non-null of the right type\nif (value == null) throw new KettleValueException(\"Condition field value is null: \" + fieldName);","typeGuard":"boolean isEvaluable(Condition c, RowMetaInterface rowMeta, Object[] row) { return c.getUsedFields().length == 0 || Arrays.stream(c.getUsedFields()).allMatch(f -> rowMeta.indexOfValue(f) >= 0); }","tryCatchPattern":"try { boolean ok = condition.evaluate(rowMeta, row); } catch (RuntimeException e) { log.error(\"Condition evaluation failed: \" + e.getMessage(), e); /* route row to error stream */ }","preventionTips":["Avoid comparing null values directly in Conditions; coalesce first","Verify condition fields match the incoming row schema after changing upstream steps","Test conditions with edge-case data (nulls, mixed types) during development","Keep PDI updated for known Condition null-comparison fixes (PDI-13227)"],"tags":["condition","runtime","null-comparison","pentaho-kettle"],"backgroundTag":"invalid-argument-value","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}