pentaho/pentaho-kettle · error · KettleXMLException

SETVARIABLE0004

SETVARIABLE0004

Error message

Unable to read step information from XML

What it means

SetVariableMeta.loadXML delegates to readData to parse the step's <fields> XML. Any exception while reading tags (field names, variable names, variable types, defaults, use_formatting) is wrapped in a KettleXMLException with message SETVARIABLE0004, meaning the step's XML definition could not be parsed.

Solutions

  1. Open the .ktr in a text editor and repair/validate the <step> XML for SetVariable, especially <fields> and <use_formatting>
  2. Re-create the Set Variable step in Spoon and re-save the transformation
  3. Check PDI version compatibility and re-export the transformation with the current version
  4. Inspect the wrapped cause exception in the log for the exact parse failure

Example fix

// before (broken XML)
<fields>
  <field>
    <name>amount</name>
<!-- missing variable_name -->
</fields>
// after
<fields>
  <field>
    <name>amount</name>
    <variable_name>AMOUNT</variable_name>
    <variable_type>0</variable_type>
    <default_value></default_value>
  </field>
</fields>
Defensive patterns

Strategy: try-catch

Validate before calling

try (InputStream is = new FileInputStream(ktrFile)) {
  Document doc = XMLHandler.loadXMLFile(is);
  // verify <step> nodes of type SetVariable contain <fields> children before loading meta
}

Try / catch

try { loadXML(...); } catch (KettleXMLException e) { if (e.getMessage().contains("SETVARIABLE0004")) { /* fall back to re-creating the step or repairing XML */ log("SetVariable XML unreadable: ", e.getCause()); } else throw e; }

Prevention

When it happens

Trigger: loadXML is called with a stepnode whose expected tags are missing/malformed, or XMLHandler.getTagValue throws during parsing.

Common situations: Hand-edited or truncated .ktr XML; importing a transformation produced by a different PDI version with changed tags; copy-paste corruption inside the step's XML node.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/setvariable/SetVariableMeta.java:217

      Node fields = XMLHandler.getSubNode( stepnode, "fields" );
      int count = XMLHandler.countNodes( fields, "field" );

      allocate( count );

      for ( int i = 0; i < count; i++ ) {
        Node fnode = XMLHandler.getSubNodeByNr( fields, "field", i );

        fieldName[i] = XMLHandler.getTagValue( fnode, "field_name" );
        variableName[i] = XMLHandler.getTagValue( fnode, "variable_name" );
        variableType[i] = getVariableType( XMLHandler.getTagValue( fnode, "variable_type" ) );
        defaultValue[i] = XMLHandler.getTagValue( fnode, "default_value" );
      }

      // Default to "N" for backward compatibility
      //
      usingFormatting = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "use_formatting" ) );
    } catch ( Exception e ) {
      throw new KettleXMLException( BaseMessages.getString(
        PKG, "SetVariableMeta.RuntimeError.UnableToReadXML.SETVARIABLE0004" ), e );
    }
  }

  public void setDefault() {
    int count = 0;

    allocate( count );

    for ( int i = 0; i < count; i++ ) {
      fieldName[i] = "field" + i;
      variableName[i] = "";
      variableType[i] = VARIABLE_TYPE_JVM;
      defaultValue[i] = "";
    }

    usingFormatting = true;
  }

View on GitHub (pinned to f3058517a1)