pentaho/pentaho-kettle · error · KettleXMLException

SwitchCaseMeta.Exception..UnableToLoadStepInfoFromXML

SwitchCaseMeta.Exception..UnableToLoadStepInfoFromXML

Error message

SwitchCaseMeta.Exception..UnableToLoadStepInfoFromXML

What it means

KettleXMLException thrown by SwitchCaseMeta.readData (invoked from loadXML) when an unexpected exception occurs while parsing the Switch/Case step's XML definition — specifically while reading case nodes into SwitchCaseTarget entries (value, target_step tags). Any XMLHandler failure or unexpected structure inside the try block is wrapped with this localized message and rethrown.

Solutions

  1. Check the chained cause for the exact XML parsing problem and fix that node in the .ktr file.
  2. Open the transformation in Spoon of the matching PDI version; if needed, export a fresh XML instead of hand-editing.
  3. Validate the .ktr XML well-formedness (XML parser/xmllint) and repair or regenerate the case nodes.
  4. Restore the file from version control or re-create the Switch/Case step if the XML is unrecoverable.
Defensive patterns

Strategy: try-catch

Validate before calling

// validate XML well-formedness before loading
try { DocumentBuilderFactory.newInstance().newDocumentBuilder().parse( new File( ktrPath ) ); }
catch ( Exception e ) { throw new IllegalStateException( "ktr XML malformed: " + ktrPath, e ); }

Try / catch

try { transMeta.loadXML( file, ... ); } catch ( KettleXMLException e ) { log.error( "Switch/Case XML load failed: " + e.getCause(), e ); throw e; }

Prevention

When it happens

Trigger: Loading a .ktr from file/XML when the <cases> nodes are malformed, the XML schema changed between Pentaho versions, or the file was hand-edited/corrupted so XMLHandler.getTagValue throws or encounters unexpected structure.

Common situations: Hand-editing ktr files and breaking the case node structure; opening transformations created in newer/older PDI versions with different XML layout; truncated or corrupted files from bad version-control merges or incomplete transfers.

Understand the failure class

Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/switchcase/SwitchCaseMeta.java:178

      caseValueType = ValueMetaBase.getType( XMLHandler.getTagValue( stepnode, "case_value_type" ) );
      caseValueFormat = XMLHandler.getTagValue( stepnode, "case_value_format" );
      caseValueDecimal = XMLHandler.getTagValue( stepnode, "case_value_decimal" );
      caseValueGroup = XMLHandler.getTagValue( stepnode, "case_value_group" );

      defaultTargetStepname = XMLHandler.getTagValue( stepnode, "default_target_step" );

      Node casesNode = XMLHandler.getSubNode( stepnode, XML_TAG_CASE_VALUES );
      int nrCases = XMLHandler.countNodes( casesNode, XML_TAG_CASE_VALUE );
      allocate();
      for ( int i = 0; i < nrCases; i++ ) {
        Node caseNode = XMLHandler.getSubNodeByNr( casesNode, XML_TAG_CASE_VALUE, i );
        SwitchCaseTarget target = new SwitchCaseTarget();
        target.caseValue = XMLHandler.getTagValue( caseNode, "value" );
        target.caseTargetStepname = XMLHandler.getTagValue( caseNode, "target_step" );
        caseTargets.add( target );
      }
    } catch ( Exception e ) {
      throw new KettleXMLException( BaseMessages.getString(
        PKG, "SwitchCaseMeta.Exception..UnableToLoadStepInfoFromXML" ), e );
    }
  }

  public void setDefault() {
    allocate();
  }

  public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ) throws KettleException {
    try {
      fieldname = rep.getStepAttributeString( id_step, "fieldname" );
      isContains = rep.getStepAttributeBoolean( id_step, "use_contains" );
      caseValueType = ValueMetaBase.getType( rep.getStepAttributeString( id_step, "case_value_type" ) );
      caseValueFormat = rep.getStepAttributeString( id_step, "case_value_format" );
      caseValueDecimal = rep.getStepAttributeString( id_step, "case_value_decimal" );
      caseValueGroup = rep.getStepAttributeString( id_step, "case_value_group" );

      defaultTargetStepname = rep.getStepAttributeString( id_step, "default_target_step" );

View on GitHub (pinned to f3058517a1)