pentaho/pentaho-kettle · error · KettleXMLException

Unable to create condition using xml:

Error message

Unable to create condition using xml: 

What it means

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.

Solutions

  1. Examine the embedded XML in the message and fix the malformed condition structure (tags, attributes, values)
  2. Recreate the condition in Spoon and re-save the transformation/job so valid XML is generated
  3. Ensure the PDI version reading the file is >= the version that wrote it

Example fix

// before
Condition c = new Condition(XMLHandler.getSubNode(ruleNode, "condition")); // hand-edited, missing <function>
// after
Validate the node first:
Node condNode = XMLHandler.getSubNode(ruleNode, "condition");
if (condNode == null || XMLHandler.getSubNode(condNode, "function") == null) throw new KettleXMLException("Invalid condition XML");
Condition c = new Condition(condNode);
Defensive patterns

Strategy: try-catch

Validate before calling

Node condNode = XMLHandler.getSubNode(parent, Condition.XML_TAG);
if (condNode == null) throw new KettleXMLException("Missing <condition> node");

Try / catch

try { Condition c = new Condition(condNode); } catch (KettleXMLException e) { log.error("Bad condition XML: " + e.getMessage()); /* fail import or substitute default condition */ }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "failed to unmarshal" / json.Unmarshal errors: why parsing a response into a Go struct fails and how to fix it — this error's family across 23 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/bcfc66e60addeb45. Report an issue: GitHub.

Appendix: source

Thrown at core/src/main/java/org/pentaho/di/core/Condition.java:852

        if ( Utils.isEmpty( rightValueName ) ) {
          rightValueName = null;
        }
        setRightValuename( rightValueName );

        Node exactnode = XMLHandler.getSubNode( condnode, ValueMetaAndData.XML_TAG );
        if ( exactnode != null ) {
          ValueMetaAndData exact = new ValueMetaAndData( exactnode );
          setRightExact( exact );
        }
      } else {
        for ( int i = 0; i < nrconditions; i++ ) {
          Node subcondnode = XMLHandler.getSubNodeByNr( conditions, XML_TAG, i );
          Condition c = new Condition( subcondnode );
          addCondition( c );
        }
      }
    } catch ( Exception e ) {
      throw new KettleXMLException( "Unable to create condition using xml: " + Const.CR + condnode, e );
    }
  }

  public String[] getUsedFields() {
    Map<String, String> fields = new HashMap<>();
    getUsedFields( fields );
    return fields.keySet().toArray( new String[0] );
  }

  public void getUsedFields( Map<String, String> fields ) {
    if ( isAtomic() ) {
      if ( getLeftValuename() != null ) {
        fields.put( getLeftValuename(), "-" );
      }
      if ( getRightValuename() != null ) {
        fields.put( getRightValuename(), "-" );
      }
    } else {

View on GitHub (pinned to f3058517a1)