{"record":{"id":"bcfc66e60addeb45","repo":"pentaho/pentaho-kettle","slug":"unable-to-create-condition-using-xml","errorCode":null,"errorMessage":"Unable to create condition using xml: ","messagePattern":"Unable to create condition using xml: ","errorType":"exception","errorClass":"KettleXMLException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/Condition.java","lineNumber":852,"sourceCode":"        if ( Utils.isEmpty( rightValueName ) ) {\n          rightValueName = null;\n        }\n        setRightValuename( rightValueName );\n\n        Node exactnode = XMLHandler.getSubNode( condnode, ValueMetaAndData.XML_TAG );\n        if ( exactnode != null ) {\n          ValueMetaAndData exact = new ValueMetaAndData( exactnode );\n          setRightExact( exact );\n        }\n      } else {\n        for ( int i = 0; i < nrconditions; i++ ) {\n          Node subcondnode = XMLHandler.getSubNodeByNr( conditions, XML_TAG, i );\n          Condition c = new Condition( subcondnode );\n          addCondition( c );\n        }\n      }\n    } catch ( Exception e ) {\n      throw new KettleXMLException( \"Unable to create condition using xml: \" + Const.CR + condnode, e );\n    }\n  }\n\n  public String[] getUsedFields() {\n    Map<String, String> fields = new HashMap<>();\n    getUsedFields( fields );\n    return fields.keySet().toArray( new String[0] );\n  }\n\n  public void getUsedFields( Map<String, String> fields ) {\n    if ( isAtomic() ) {\n      if ( getLeftValuename() != null ) {\n        fields.put( getLeftValuename(), \"-\" );\n      }\n      if ( getRightValuename() != null ) {\n        fields.put( getRightValuename(), \"-\" );\n      }\n    } else {","sourceCodeStart":834,"sourceCodeEnd":870,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/Condition.java#L834-L870","documentation":"The Condition(Node) constructor deserializes a condition from an XML node (as produced by getXML()). Any failure while parsing — missing sub-nodes, malformed values for field/function/operator, or an invalid nested composite condition — is wrapped in KettleXMLException 'Unable to create condition using xml: <node>'. The offending XML is appended to the message to aid diagnosis.","triggerScenarios":"new Condition(condNode) on XML that is not a valid serialized Condition: wrong tag structure, missing required child nodes, or sub-conditions whose recursive parsing throws; typically during reading transformations/jobs from XML repositories or .ktr/.kjb files.","commonSituations":"Hand-edited or corrupted .ktr/.kjb files; XML written by a newer PDI version being read by an older one (schema drift); repository import of partially corrupted metadata.","solutions":["Examine the embedded XML in the message and fix the malformed condition structure (tags, attributes, values)","Recreate the condition in Spoon and re-save the transformation/job so valid XML is generated","Ensure the PDI version reading the file is >= the version that wrote it"],"exampleFix":"// before\nCondition c = new Condition(XMLHandler.getSubNode(ruleNode, \"condition\")); // hand-edited, missing <function>\n// after\nValidate the node first:\nNode condNode = XMLHandler.getSubNode(ruleNode, \"condition\");\nif (condNode == null || XMLHandler.getSubNode(condNode, \"function\") == null) throw new KettleXMLException(\"Invalid condition XML\");\nCondition c = new Condition(condNode);","handlingStrategy":"try-catch","validationCode":"Node condNode = XMLHandler.getSubNode(parent, Condition.XML_TAG);\nif (condNode == null) throw new KettleXMLException(\"Missing <condition> node\");","typeGuard":null,"tryCatchPattern":"try { Condition c = new Condition(condNode); } catch (KettleXMLException e) { log.error(\"Bad condition XML: \" + e.getMessage()); /* fail import or substitute default condition */ }","preventionTips":["Do not hand-edit .ktr/.kjb XML; edit conditions in Spoon","Keep reader PDI version >= writer version","Validate exported XML before importing into another repository"],"tags":["xml","deserialization","condition","pentaho-kettle"],"backgroundTag":"json-unmarshal-failed","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"}